From a884aa6326dc5e57ec19ec2bc8917bccfb60ce45 Mon Sep 17 00:00:00 2001 From: ukrbublik Date: Wed, 19 Jun 2024 18:59:40 +0300 Subject: [PATCH] 2 tests --- CHANGELOG.md | 1 + packages/tests/specs/SwitchCase.test.ts | 8 ++++++++ packages/tests/support/inits.js | 18 ++++++++++++++++++ packages/tests/support/utils.tsx | 2 +- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a68ed5e0..d22c112f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed import of negative number in SpEL (PR #1054) (issue #1055) - Fixed validation error message for min/max (PR #1058) (issue #1057) - (Ternary mode) Added to `config.settings`: `caseValueField`, `renderBeforeCaseValue`, `renderAfterCaseValue`, `renderSwitchPrefix`, `defaultCaseLabel`, `addCaseLabel`, `addDefaultCaseLabel` (PR #1062) + - Use icon button label as the aria-label to improve accessibility (PR #1066) (issue #1038) - 6.5.2 - Updated dependencies. `@babel/runtime` is now dep for core package (PR #1051) (issue #964) - 6.5.1 diff --git a/packages/tests/specs/SwitchCase.test.ts b/packages/tests/specs/SwitchCase.test.ts index 5eba7c32c..5e1d68284 100644 --- a/packages/tests/specs/SwitchCase.test.ts +++ b/packages/tests/specs/SwitchCase.test.ts @@ -19,6 +19,10 @@ describe("query with switch-case", () => { ]} ]} }); + + export_checks([configs.with_all_types, configs.with_cases], inits.with_cases, undefined, { + "spel": "(str == '222' ? 'is_string' : (num == 4 ? 'is_number' : 'unknown'))", + }); }); describe("1 case and 1 default", () => { @@ -32,6 +36,10 @@ describe("query with switch-case", () => { ] } }); + + export_checks([configs.with_all_types, configs.with_cases], inits.with_cases_simple, undefined, { + spel: "(str == '222' ? 'foo' : 'bar')" + }); }); describe("with concat in value", () => { diff --git a/packages/tests/support/inits.js b/packages/tests/support/inits.js index 87186513c..ba9ad57aa 100644 --- a/packages/tests/support/inits.js +++ b/packages/tests/support/inits.js @@ -1483,6 +1483,24 @@ export const spel_with_cases = "(str == '222' ? is_string : (num == 4 ? is_numbe export const spel_with_cases_simple = "(str == '222' ? foo : bar)"; export const spel_with_cases_and_concat = "(str == '222' ? foo : foo + bar)"; +export const with_cases = {"if": [ + {"==":[{"var":"str"},"222"]}, + "is_string", + {"if": [ + {"==":[{"var":"num"},4]}, + "is_number", + "unknown" + ]} +]}; + +export const with_cases_simple = { + "if": [ + {"==": [{"var": "str"}, "222"]}, + "foo", + "bar" + ] +}; + export const spel_with_lhs_toLowerCase = "str.toLowerCase().startsWith('aaa')"; export const spel_with_lhs_toLowerCase_toUpperCase = "str.toLowerCase().toUpperCase() == str.toUpperCase()"; //export const spel_with_new_Date = "datetime == new java.util.Date()"; diff --git a/packages/tests/support/utils.tsx b/packages/tests/support/utils.tsx index 9de5a8bb9..d2a63bd58 100644 --- a/packages/tests/support/utils.tsx +++ b/packages/tests/support/utils.tsx @@ -60,7 +60,7 @@ interface MockedConsole extends Console { __origConsole: Console; __consoleData: ConsoleData; } -type TreeValueFormat = "JsonLogic" | "default" | "SpEL" | null; +type TreeValueFormat = "JsonLogic" | "default" | "SpEL" | null | undefined; type TreeValue = JsonLogicTree | JsonTree | string | undefined; type ConfigFn = (_: Config) => Config; type ConfigFns = ConfigFn | ConfigFn[];