@@ -2,60 +2,9 @@ jest.mock("mendix/filters/builders");
2
2
3
3
import { AndCondition , FilterCondition } from "mendix/filters" ;
4
4
import { equals , literal } from "mendix/filters/builders" ;
5
- import {
6
- compactArray ,
7
- fromCompactArray ,
8
- reduceArray ,
9
- reduceMap ,
10
- restoreArray ,
11
- restoreMap ,
12
- tag
13
- } from "../condition-utils" ;
5
+ import { reduceArray , reduceMap , restoreArray , restoreMap , tag } from "../condition-utils" ;
14
6
15
7
describe ( "condition-utils" , ( ) => {
16
- describe ( "compactArray" , ( ) => {
17
- it ( "returns 'tag' condition for zero array" , ( ) => {
18
- const result = compactArray ( [ ] ) ;
19
- expect ( result ) . toMatchObject ( {
20
- name : "!=" ,
21
- type : "function" ,
22
- arg1 : { value : "[0,[]]" , valueType : "String" }
23
- } ) ;
24
- } ) ;
25
-
26
- it ( "returns 'tag' condition for array of undefined" , ( ) => {
27
- const result = compactArray ( [ undefined , undefined , undefined ] ) ;
28
- expect ( result ) . toMatchObject ( {
29
- name : "!=" ,
30
- type : "function" ,
31
- arg1 : { value : "[3,[]]" , valueType : "String" }
32
- } ) ;
33
- } ) ;
34
-
35
- it ( "returns 'and' condition with 3 args" , ( ) => {
36
- const result = compactArray ( [ tag ( "0" ) , undefined , tag ( "2" ) ] ) ;
37
- expect ( result ) . toMatchObject ( { name : "and" , type : "function" } ) ;
38
- expect ( ( result as AndCondition ) . args ) . toHaveLength ( 3 ) ;
39
- } ) ;
40
- } ) ;
41
-
42
- describe ( "fromCompactArray" , ( ) => {
43
- it ( "unpack condition created with compactArray" , ( ) => {
44
- const input = [
45
- equals ( literal ( "1" ) , literal ( "1" ) ) ,
46
- undefined ,
47
- equals ( literal ( "foo" ) , literal ( "bar" ) ) ,
48
- undefined ,
49
- undefined ,
50
- equals ( literal ( new Date ( "2024-09-17T14:00:00.000Z" ) ) , literal ( new Date ( "2024-09-17T14:00:00.000Z" ) ) )
51
- ] ;
52
- const cond = compactArray ( input ) ;
53
- expect ( cond ) . toBeDefined ( ) ;
54
- const result = fromCompactArray ( cond ! ) ;
55
- expect ( result ) . toEqual ( input ) ;
56
- } ) ;
57
- } ) ;
58
-
59
8
describe ( "reduceMap" , ( ) => {
60
9
it ( "returns undefined condition and correct metadata for map with undefined values" , ( ) => {
61
10
const input = { x : undefined , y : undefined } ;
0 commit comments