@usertour/helpers 0.0.32 → 0.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/attribute.test.cjs +477 -40
- package/dist/__tests__/attribute.test.js +465 -29
- package/dist/__tests__/condition.test.cjs +13 -12
- package/dist/__tests__/condition.test.js +2 -2
- package/dist/{chunk-P46FJFKP.js → chunk-7JXEY4A2.js} +13 -12
- package/dist/{chunk-VBHUPKP7.js → chunk-A4KMGXB3.js} +1 -1
- package/dist/conditions/attribute.cjs +13 -12
- package/dist/conditions/attribute.js +1 -1
- package/dist/conditions/condition.cjs +13 -12
- package/dist/conditions/condition.js +2 -2
- package/dist/conditions/index.cjs +13 -12
- package/dist/conditions/index.js +2 -2
- package/dist/index.cjs +13 -12
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -110,26 +110,27 @@ function evaluateStringCondition(logic, actualValue, expectedValue) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
function evaluateNumberCondition(logic, actualValue, expectedValue, expectedValue2) {
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
|
|
113
|
+
const numActualValue = Number(actualValue);
|
|
114
|
+
const numExpectedValue = Number(expectedValue);
|
|
115
|
+
const numExpectedValue2 = Number(expectedValue2);
|
|
116
|
+
if (Number.isNaN(numActualValue)) {
|
|
116
117
|
return false;
|
|
117
118
|
}
|
|
118
119
|
switch (logic) {
|
|
119
120
|
case "is":
|
|
120
|
-
return
|
|
121
|
+
return numActualValue === numExpectedValue;
|
|
121
122
|
case "not":
|
|
122
|
-
return
|
|
123
|
+
return numActualValue !== numExpectedValue;
|
|
123
124
|
case "isLessThan":
|
|
124
|
-
return
|
|
125
|
+
return numActualValue < numExpectedValue;
|
|
125
126
|
case "isLessThanOrEqualTo":
|
|
126
|
-
return
|
|
127
|
+
return numActualValue <= numExpectedValue;
|
|
127
128
|
case "isGreaterThan":
|
|
128
|
-
return
|
|
129
|
+
return numActualValue > numExpectedValue;
|
|
129
130
|
case "isGreaterThanOrEqualTo":
|
|
130
|
-
return
|
|
131
|
+
return numActualValue >= numExpectedValue;
|
|
131
132
|
case "between":
|
|
132
|
-
return
|
|
133
|
+
return numActualValue >= numExpectedValue && numActualValue <= numExpectedValue2;
|
|
133
134
|
case "empty":
|
|
134
135
|
return actualValue === null || actualValue === void 0 || actualValue === "";
|
|
135
136
|
case "any":
|
|
@@ -176,9 +177,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
176
177
|
case "includesAll":
|
|
177
178
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
178
179
|
case "notIncludesAtLeastOne":
|
|
179
|
-
return
|
|
180
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
180
181
|
case "notIncludesAll":
|
|
181
|
-
return
|
|
182
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
182
183
|
default:
|
|
183
184
|
return false;
|
|
184
185
|
}
|
|
@@ -271,6 +272,12 @@ var testAttributes = [
|
|
|
271
272
|
dataType: import_types2.BizAttributeTypes.List,
|
|
272
273
|
bizType: import_types2.AttributeBizTypes.User
|
|
273
274
|
},
|
|
275
|
+
{
|
|
276
|
+
id: "tags-attr",
|
|
277
|
+
codeName: "tags",
|
|
278
|
+
dataType: import_types2.BizAttributeTypes.List,
|
|
279
|
+
bizType: import_types2.AttributeBizTypes.User
|
|
280
|
+
},
|
|
274
281
|
{
|
|
275
282
|
id: "signUpDate-attr",
|
|
276
283
|
codeName: "signUpDate",
|
|
@@ -283,6 +290,12 @@ var testAttributes = [
|
|
|
283
290
|
dataType: import_types2.BizAttributeTypes.Number,
|
|
284
291
|
bizType: import_types2.AttributeBizTypes.User
|
|
285
292
|
},
|
|
293
|
+
{
|
|
294
|
+
id: "sdsdd-attr",
|
|
295
|
+
codeName: "sdsdd",
|
|
296
|
+
dataType: import_types2.BizAttributeTypes.Number,
|
|
297
|
+
bizType: import_types2.AttributeBizTypes.User
|
|
298
|
+
},
|
|
286
299
|
// Company attributes
|
|
287
300
|
{
|
|
288
301
|
id: "company-name-attr",
|
|
@@ -315,8 +328,10 @@ var testUserAttributes = {
|
|
|
315
328
|
age: 25,
|
|
316
329
|
isPremium: true,
|
|
317
330
|
roles: ["admin", "user"],
|
|
331
|
+
tags: [123, 456],
|
|
318
332
|
signUpDate: "2024-01-15T10:30:00Z",
|
|
319
|
-
score: 85.5
|
|
333
|
+
score: 85.5,
|
|
334
|
+
sdsdd: 101
|
|
320
335
|
};
|
|
321
336
|
var testCompanyAttributes = {
|
|
322
337
|
companyName: "Example Corp",
|
|
@@ -589,6 +604,229 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
589
604
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
590
605
|
});
|
|
591
606
|
});
|
|
607
|
+
describe("Number conditions with string values", () => {
|
|
608
|
+
test('should evaluate "is" condition when actualValue is number and expectedValue is string', () => {
|
|
609
|
+
const condition = [
|
|
610
|
+
{
|
|
611
|
+
id: "number-string-condition-1",
|
|
612
|
+
type: "condition",
|
|
613
|
+
operators: "and",
|
|
614
|
+
data: {
|
|
615
|
+
logic: "is",
|
|
616
|
+
value: "101",
|
|
617
|
+
attrId: "sdsdd-attr"
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
];
|
|
621
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
622
|
+
});
|
|
623
|
+
test('should evaluate "is" condition when actualValue is string and expectedValue is number', () => {
|
|
624
|
+
const userAttributesWithStringNumber = {
|
|
625
|
+
...testUserAttributes,
|
|
626
|
+
sdsdd: "101"
|
|
627
|
+
};
|
|
628
|
+
const condition = [
|
|
629
|
+
{
|
|
630
|
+
id: "number-string-condition-2",
|
|
631
|
+
type: "condition",
|
|
632
|
+
operators: "and",
|
|
633
|
+
data: {
|
|
634
|
+
logic: "is",
|
|
635
|
+
value: 101,
|
|
636
|
+
attrId: "sdsdd-attr"
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
];
|
|
640
|
+
expect(
|
|
641
|
+
evaluateFilterConditions(condition, {
|
|
642
|
+
...defaultOptions,
|
|
643
|
+
userAttributes: userAttributesWithStringNumber
|
|
644
|
+
})
|
|
645
|
+
).toBe(true);
|
|
646
|
+
});
|
|
647
|
+
test('should evaluate "is" condition when both actualValue and expectedValue are strings', () => {
|
|
648
|
+
const userAttributesWithStringNumber = {
|
|
649
|
+
...testUserAttributes,
|
|
650
|
+
sdsdd: "101"
|
|
651
|
+
};
|
|
652
|
+
const condition = [
|
|
653
|
+
{
|
|
654
|
+
id: "number-string-condition-3",
|
|
655
|
+
type: "condition",
|
|
656
|
+
operators: "and",
|
|
657
|
+
data: {
|
|
658
|
+
logic: "is",
|
|
659
|
+
value: "101",
|
|
660
|
+
attrId: "sdsdd-attr"
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
];
|
|
664
|
+
expect(
|
|
665
|
+
evaluateFilterConditions(condition, {
|
|
666
|
+
...defaultOptions,
|
|
667
|
+
userAttributes: userAttributesWithStringNumber
|
|
668
|
+
})
|
|
669
|
+
).toBe(true);
|
|
670
|
+
});
|
|
671
|
+
test('should evaluate "not" condition when actualValue is number and expectedValue is string', () => {
|
|
672
|
+
const condition = [
|
|
673
|
+
{
|
|
674
|
+
id: "number-string-condition-4",
|
|
675
|
+
type: "condition",
|
|
676
|
+
operators: "and",
|
|
677
|
+
data: {
|
|
678
|
+
logic: "not",
|
|
679
|
+
value: "102",
|
|
680
|
+
attrId: "sdsdd-attr"
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
];
|
|
684
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
685
|
+
});
|
|
686
|
+
test('should evaluate "isLessThan" condition when expectedValue is string', () => {
|
|
687
|
+
const condition = [
|
|
688
|
+
{
|
|
689
|
+
id: "number-string-condition-5",
|
|
690
|
+
type: "condition",
|
|
691
|
+
operators: "and",
|
|
692
|
+
data: {
|
|
693
|
+
logic: "isLessThan",
|
|
694
|
+
value: "102",
|
|
695
|
+
attrId: "sdsdd-attr"
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
];
|
|
699
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
700
|
+
});
|
|
701
|
+
test('should evaluate "isGreaterThan" condition when expectedValue is string', () => {
|
|
702
|
+
const condition = [
|
|
703
|
+
{
|
|
704
|
+
id: "number-string-condition-6",
|
|
705
|
+
type: "condition",
|
|
706
|
+
operators: "and",
|
|
707
|
+
data: {
|
|
708
|
+
logic: "isGreaterThan",
|
|
709
|
+
value: "100",
|
|
710
|
+
attrId: "sdsdd-attr"
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
];
|
|
714
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
715
|
+
});
|
|
716
|
+
test('should evaluate "between" condition when value and value2 are strings', () => {
|
|
717
|
+
const condition = [
|
|
718
|
+
{
|
|
719
|
+
id: "number-string-condition-7",
|
|
720
|
+
type: "condition",
|
|
721
|
+
operators: "and",
|
|
722
|
+
data: {
|
|
723
|
+
logic: "between",
|
|
724
|
+
value: "100",
|
|
725
|
+
value2: "103",
|
|
726
|
+
attrId: "sdsdd-attr"
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
];
|
|
730
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
731
|
+
});
|
|
732
|
+
test('should evaluate "between" condition when actualValue is string and values are strings', () => {
|
|
733
|
+
const userAttributesWithStringNumber = {
|
|
734
|
+
...testUserAttributes,
|
|
735
|
+
sdsdd: "101"
|
|
736
|
+
};
|
|
737
|
+
const condition = [
|
|
738
|
+
{
|
|
739
|
+
id: "number-string-condition-8",
|
|
740
|
+
type: "condition",
|
|
741
|
+
operators: "and",
|
|
742
|
+
data: {
|
|
743
|
+
logic: "between",
|
|
744
|
+
value: "100",
|
|
745
|
+
value2: "103",
|
|
746
|
+
attrId: "sdsdd-attr"
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
];
|
|
750
|
+
expect(
|
|
751
|
+
evaluateFilterConditions(condition, {
|
|
752
|
+
...defaultOptions,
|
|
753
|
+
userAttributes: userAttributesWithStringNumber
|
|
754
|
+
})
|
|
755
|
+
).toBe(true);
|
|
756
|
+
});
|
|
757
|
+
test("should return false when actualValue is NaN", () => {
|
|
758
|
+
const userAttributesWithNaN = {
|
|
759
|
+
...testUserAttributes,
|
|
760
|
+
sdsdd: "not-a-number"
|
|
761
|
+
};
|
|
762
|
+
const condition = [
|
|
763
|
+
{
|
|
764
|
+
id: "number-string-condition-9",
|
|
765
|
+
type: "condition",
|
|
766
|
+
operators: "and",
|
|
767
|
+
data: {
|
|
768
|
+
logic: "is",
|
|
769
|
+
value: 101,
|
|
770
|
+
attrId: "sdsdd-attr"
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
];
|
|
774
|
+
expect(
|
|
775
|
+
evaluateFilterConditions(condition, {
|
|
776
|
+
...defaultOptions,
|
|
777
|
+
userAttributes: userAttributesWithNaN
|
|
778
|
+
})
|
|
779
|
+
).toBe(false);
|
|
780
|
+
});
|
|
781
|
+
test("should handle decimal string values correctly", () => {
|
|
782
|
+
const userAttributesWithDecimal = {
|
|
783
|
+
...testUserAttributes,
|
|
784
|
+
score: "85.5"
|
|
785
|
+
};
|
|
786
|
+
const condition = [
|
|
787
|
+
{
|
|
788
|
+
id: "number-string-condition-10",
|
|
789
|
+
type: "condition",
|
|
790
|
+
operators: "and",
|
|
791
|
+
data: {
|
|
792
|
+
logic: "is",
|
|
793
|
+
value: "85.5",
|
|
794
|
+
attrId: "score-attr"
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
];
|
|
798
|
+
expect(
|
|
799
|
+
evaluateFilterConditions(condition, {
|
|
800
|
+
...defaultOptions,
|
|
801
|
+
userAttributes: userAttributesWithDecimal
|
|
802
|
+
})
|
|
803
|
+
).toBe(true);
|
|
804
|
+
});
|
|
805
|
+
test("should handle negative string values correctly", () => {
|
|
806
|
+
const userAttributesWithNegative = {
|
|
807
|
+
...testUserAttributes,
|
|
808
|
+
sdsdd: "-50"
|
|
809
|
+
};
|
|
810
|
+
const condition = [
|
|
811
|
+
{
|
|
812
|
+
id: "number-string-condition-11",
|
|
813
|
+
type: "condition",
|
|
814
|
+
operators: "and",
|
|
815
|
+
data: {
|
|
816
|
+
logic: "isLessThan",
|
|
817
|
+
value: "0",
|
|
818
|
+
attrId: "sdsdd-attr"
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
];
|
|
822
|
+
expect(
|
|
823
|
+
evaluateFilterConditions(condition, {
|
|
824
|
+
...defaultOptions,
|
|
825
|
+
userAttributes: userAttributesWithNegative
|
|
826
|
+
})
|
|
827
|
+
).toBe(true);
|
|
828
|
+
});
|
|
829
|
+
});
|
|
592
830
|
describe("Boolean conditions (4 cases)", () => {
|
|
593
831
|
test('should evaluate "true" condition correctly', () => {
|
|
594
832
|
const condition = [
|
|
@@ -678,35 +916,234 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
678
916
|
];
|
|
679
917
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
680
918
|
});
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
919
|
+
describe("notIncludesAtLeastOne condition", () => {
|
|
920
|
+
test("should return true when at least one value is not included (single value not included)", () => {
|
|
921
|
+
const condition = [
|
|
922
|
+
{
|
|
923
|
+
id: "condition-24",
|
|
924
|
+
type: "condition",
|
|
925
|
+
operators: "and",
|
|
926
|
+
data: {
|
|
927
|
+
logic: "notIncludesAtLeastOne",
|
|
928
|
+
listValues: ["guest"],
|
|
929
|
+
attrId: "roles-attr"
|
|
930
|
+
}
|
|
691
931
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
932
|
+
];
|
|
933
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
934
|
+
});
|
|
935
|
+
test("should return true when at least one value is not included (partial values not included)", () => {
|
|
936
|
+
const condition = [
|
|
937
|
+
{
|
|
938
|
+
id: "condition-24-2",
|
|
939
|
+
type: "condition",
|
|
940
|
+
operators: "and",
|
|
941
|
+
data: {
|
|
942
|
+
logic: "notIncludesAtLeastOne",
|
|
943
|
+
listValues: ["admin", "guest"],
|
|
944
|
+
attrId: "roles-attr"
|
|
945
|
+
}
|
|
706
946
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
947
|
+
];
|
|
948
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
949
|
+
});
|
|
950
|
+
test("should return true when all values are not included", () => {
|
|
951
|
+
const condition = [
|
|
952
|
+
{
|
|
953
|
+
id: "condition-24-3",
|
|
954
|
+
type: "condition",
|
|
955
|
+
operators: "and",
|
|
956
|
+
data: {
|
|
957
|
+
logic: "notIncludesAtLeastOne",
|
|
958
|
+
listValues: ["guest", "visitor"],
|
|
959
|
+
attrId: "roles-attr"
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
];
|
|
963
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
964
|
+
});
|
|
965
|
+
test("should return false when all values are included", () => {
|
|
966
|
+
const condition = [
|
|
967
|
+
{
|
|
968
|
+
id: "condition-24-4",
|
|
969
|
+
type: "condition",
|
|
970
|
+
operators: "and",
|
|
971
|
+
data: {
|
|
972
|
+
logic: "notIncludesAtLeastOne",
|
|
973
|
+
listValues: ["admin", "user"],
|
|
974
|
+
attrId: "roles-attr"
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
];
|
|
978
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
979
|
+
});
|
|
980
|
+
test("should return false when single value is included", () => {
|
|
981
|
+
const condition = [
|
|
982
|
+
{
|
|
983
|
+
id: "condition-24-5",
|
|
984
|
+
type: "condition",
|
|
985
|
+
operators: "and",
|
|
986
|
+
data: {
|
|
987
|
+
logic: "notIncludesAtLeastOne",
|
|
988
|
+
listValues: ["admin"],
|
|
989
|
+
attrId: "roles-attr"
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
];
|
|
993
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
994
|
+
});
|
|
995
|
+
test("should return true for numeric list when at least one value is not included", () => {
|
|
996
|
+
const condition = [
|
|
997
|
+
{
|
|
998
|
+
id: "condition-24-6",
|
|
999
|
+
type: "condition",
|
|
1000
|
+
operators: "and",
|
|
1001
|
+
data: {
|
|
1002
|
+
logic: "notIncludesAtLeastOne",
|
|
1003
|
+
listValues: [123, 444],
|
|
1004
|
+
attrId: "tags-attr"
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
];
|
|
1008
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
1009
|
+
});
|
|
1010
|
+
test("should return false for numeric list when all values are included", () => {
|
|
1011
|
+
const condition = [
|
|
1012
|
+
{
|
|
1013
|
+
id: "condition-24-7",
|
|
1014
|
+
type: "condition",
|
|
1015
|
+
operators: "and",
|
|
1016
|
+
data: {
|
|
1017
|
+
logic: "notIncludesAtLeastOne",
|
|
1018
|
+
listValues: [123, 456],
|
|
1019
|
+
attrId: "tags-attr"
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
];
|
|
1023
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
describe("notIncludesAll condition", () => {
|
|
1027
|
+
test("should return true when all values are not included", () => {
|
|
1028
|
+
const condition = [
|
|
1029
|
+
{
|
|
1030
|
+
id: "condition-25",
|
|
1031
|
+
type: "condition",
|
|
1032
|
+
operators: "and",
|
|
1033
|
+
data: {
|
|
1034
|
+
logic: "notIncludesAll",
|
|
1035
|
+
listValues: ["guest", "visitor"],
|
|
1036
|
+
attrId: "roles-attr"
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
];
|
|
1040
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
1041
|
+
});
|
|
1042
|
+
test("should return true when single value is not included", () => {
|
|
1043
|
+
const condition = [
|
|
1044
|
+
{
|
|
1045
|
+
id: "condition-25-2",
|
|
1046
|
+
type: "condition",
|
|
1047
|
+
operators: "and",
|
|
1048
|
+
data: {
|
|
1049
|
+
logic: "notIncludesAll",
|
|
1050
|
+
listValues: ["guest"],
|
|
1051
|
+
attrId: "roles-attr"
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
];
|
|
1055
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
1056
|
+
});
|
|
1057
|
+
test("should return false when at least one value is included", () => {
|
|
1058
|
+
const condition = [
|
|
1059
|
+
{
|
|
1060
|
+
id: "condition-25-3",
|
|
1061
|
+
type: "condition",
|
|
1062
|
+
operators: "and",
|
|
1063
|
+
data: {
|
|
1064
|
+
logic: "notIncludesAll",
|
|
1065
|
+
listValues: ["admin", "guest"],
|
|
1066
|
+
attrId: "roles-attr"
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
];
|
|
1070
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1071
|
+
});
|
|
1072
|
+
test("should return false when all values are included", () => {
|
|
1073
|
+
const condition = [
|
|
1074
|
+
{
|
|
1075
|
+
id: "condition-25-4",
|
|
1076
|
+
type: "condition",
|
|
1077
|
+
operators: "and",
|
|
1078
|
+
data: {
|
|
1079
|
+
logic: "notIncludesAll",
|
|
1080
|
+
listValues: ["admin", "user"],
|
|
1081
|
+
attrId: "roles-attr"
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
];
|
|
1085
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1086
|
+
});
|
|
1087
|
+
test("should return false when single value is included", () => {
|
|
1088
|
+
const condition = [
|
|
1089
|
+
{
|
|
1090
|
+
id: "condition-25-5",
|
|
1091
|
+
type: "condition",
|
|
1092
|
+
operators: "and",
|
|
1093
|
+
data: {
|
|
1094
|
+
logic: "notIncludesAll",
|
|
1095
|
+
listValues: ["admin"],
|
|
1096
|
+
attrId: "roles-attr"
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
];
|
|
1100
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1101
|
+
});
|
|
1102
|
+
test("should return true for numeric list when all values are not included", () => {
|
|
1103
|
+
const condition = [
|
|
1104
|
+
{
|
|
1105
|
+
id: "condition-25-6",
|
|
1106
|
+
type: "condition",
|
|
1107
|
+
operators: "and",
|
|
1108
|
+
data: {
|
|
1109
|
+
logic: "notIncludesAll",
|
|
1110
|
+
listValues: [1234, 789],
|
|
1111
|
+
attrId: "tags-attr"
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
];
|
|
1115
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
1116
|
+
});
|
|
1117
|
+
test("should return false for numeric list when at least one value is included", () => {
|
|
1118
|
+
const condition = [
|
|
1119
|
+
{
|
|
1120
|
+
id: "condition-25-7",
|
|
1121
|
+
type: "condition",
|
|
1122
|
+
operators: "and",
|
|
1123
|
+
data: {
|
|
1124
|
+
logic: "notIncludesAll",
|
|
1125
|
+
listValues: [123, 444],
|
|
1126
|
+
attrId: "tags-attr"
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
];
|
|
1130
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1131
|
+
});
|
|
1132
|
+
test("should return false for numeric list when all values are included", () => {
|
|
1133
|
+
const condition = [
|
|
1134
|
+
{
|
|
1135
|
+
id: "condition-25-8",
|
|
1136
|
+
type: "condition",
|
|
1137
|
+
operators: "and",
|
|
1138
|
+
data: {
|
|
1139
|
+
logic: "notIncludesAll",
|
|
1140
|
+
listValues: [123, 456],
|
|
1141
|
+
attrId: "tags-attr"
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
];
|
|
1145
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
1146
|
+
});
|
|
710
1147
|
});
|
|
711
1148
|
test('should evaluate "empty" condition correctly', () => {
|
|
712
1149
|
const condition = [
|