@featurevisor/sdk 1.2.3 → 1.11.1
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/.eslintcache +1 -1
- package/CHANGELOG.md +19 -0
- package/coverage/clover.xml +325 -322
- package/coverage/coverage-final.json +5 -5
- package/coverage/lcov-report/bucket.ts.html +1 -1
- package/coverage/lcov-report/conditions.ts.html +58 -10
- package/coverage/lcov-report/datafileReader.ts.html +1 -1
- package/coverage/lcov-report/emitter.ts.html +1 -1
- package/coverage/lcov-report/feature.ts.html +35 -5
- package/coverage/lcov-report/index.html +11 -11
- package/coverage/lcov-report/instance.ts.html +33 -6
- package/coverage/lcov-report/logger.ts.html +11 -11
- package/coverage/lcov-report/segments.ts.html +15 -9
- package/coverage/lcov.info +575 -572
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/lib/conditions.d.ts +2 -1
- package/lib/conditions.js +18 -6
- package/lib/conditions.js.map +1 -1
- package/lib/feature.d.ts +4 -3
- package/lib/feature.js +7 -7
- package/lib/feature.js.map +1 -1
- package/lib/instance.js +8 -8
- package/lib/instance.js.map +1 -1
- package/lib/segments.d.ts +3 -2
- package/lib/segments.js +8 -8
- package/lib/segments.js.map +1 -1
- package/package.json +3 -3
- package/src/conditions.spec.ts +358 -192
- package/src/conditions.ts +20 -4
- package/src/feature.ts +13 -3
- package/src/instance.ts +13 -4
- package/src/segments.spec.ts +56 -28
- package/src/segments.ts +9 -7
package/src/conditions.spec.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { allConditionsAreMatched } from "./conditions";
|
|
2
1
|
import { Condition } from "@featurevisor/types";
|
|
3
2
|
|
|
3
|
+
import { allConditionsAreMatched } from "./conditions";
|
|
4
|
+
import { createLogger } from "./logger";
|
|
5
|
+
|
|
4
6
|
describe("sdk: Conditions", function () {
|
|
7
|
+
const logger = createLogger();
|
|
8
|
+
|
|
5
9
|
it("should be a function", function () {
|
|
6
10
|
expect(typeof allConditionsAreMatched).toEqual("function");
|
|
7
11
|
});
|
|
@@ -17,10 +21,12 @@ describe("sdk: Conditions", function () {
|
|
|
17
21
|
];
|
|
18
22
|
|
|
19
23
|
// match
|
|
20
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(true);
|
|
24
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" }, logger)).toEqual(true);
|
|
21
25
|
|
|
22
26
|
// not match
|
|
23
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" })).toEqual(
|
|
27
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" }, logger)).toEqual(
|
|
28
|
+
false,
|
|
29
|
+
);
|
|
24
30
|
});
|
|
25
31
|
|
|
26
32
|
it("should match with operator: notEquals", function () {
|
|
@@ -33,10 +39,14 @@ describe("sdk: Conditions", function () {
|
|
|
33
39
|
];
|
|
34
40
|
|
|
35
41
|
// match
|
|
36
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" })).toEqual(
|
|
42
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" }, logger)).toEqual(
|
|
43
|
+
true,
|
|
44
|
+
);
|
|
37
45
|
|
|
38
46
|
// not match
|
|
39
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(
|
|
47
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" }, logger)).toEqual(
|
|
48
|
+
false,
|
|
49
|
+
);
|
|
40
50
|
});
|
|
41
51
|
|
|
42
52
|
it("should match with operator: startsWith", function () {
|
|
@@ -49,11 +59,11 @@ describe("sdk: Conditions", function () {
|
|
|
49
59
|
];
|
|
50
60
|
|
|
51
61
|
// match
|
|
52
|
-
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true);
|
|
53
|
-
expect(allConditionsAreMatched(conditions, { name: "Hello Universe" })).toEqual(true);
|
|
62
|
+
expect(allConditionsAreMatched(conditions, { name: "Hello World" }, logger)).toEqual(true);
|
|
63
|
+
expect(allConditionsAreMatched(conditions, { name: "Hello Universe" }, logger)).toEqual(true);
|
|
54
64
|
|
|
55
65
|
// not match
|
|
56
|
-
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(false);
|
|
66
|
+
expect(allConditionsAreMatched(conditions, { name: "Hi World" }, logger)).toEqual(false);
|
|
57
67
|
});
|
|
58
68
|
|
|
59
69
|
it("should match with operator: endsWith", function () {
|
|
@@ -66,11 +76,11 @@ describe("sdk: Conditions", function () {
|
|
|
66
76
|
];
|
|
67
77
|
|
|
68
78
|
// match
|
|
69
|
-
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true);
|
|
70
|
-
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(true);
|
|
79
|
+
expect(allConditionsAreMatched(conditions, { name: "Hello World" }, logger)).toEqual(true);
|
|
80
|
+
expect(allConditionsAreMatched(conditions, { name: "Hi World" }, logger)).toEqual(true);
|
|
71
81
|
|
|
72
82
|
// not match
|
|
73
|
-
expect(allConditionsAreMatched(conditions, { name: "Hi Universe" })).toEqual(false);
|
|
83
|
+
expect(allConditionsAreMatched(conditions, { name: "Hi Universe" }, logger)).toEqual(false);
|
|
74
84
|
});
|
|
75
85
|
|
|
76
86
|
it("should match with operator: contains", function () {
|
|
@@ -83,11 +93,11 @@ describe("sdk: Conditions", function () {
|
|
|
83
93
|
];
|
|
84
94
|
|
|
85
95
|
// match
|
|
86
|
-
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(true);
|
|
87
|
-
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" })).toEqual(true);
|
|
96
|
+
expect(allConditionsAreMatched(conditions, { name: "Hello World" }, logger)).toEqual(true);
|
|
97
|
+
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" }, logger)).toEqual(true);
|
|
88
98
|
|
|
89
99
|
// not match
|
|
90
|
-
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(false);
|
|
100
|
+
expect(allConditionsAreMatched(conditions, { name: "Hi World" }, logger)).toEqual(false);
|
|
91
101
|
});
|
|
92
102
|
|
|
93
103
|
it("should match with operator: notContains", function () {
|
|
@@ -100,11 +110,11 @@ describe("sdk: Conditions", function () {
|
|
|
100
110
|
];
|
|
101
111
|
|
|
102
112
|
// match
|
|
103
|
-
expect(allConditionsAreMatched(conditions, { name: "Hi World" })).toEqual(true);
|
|
113
|
+
expect(allConditionsAreMatched(conditions, { name: "Hi World" }, logger)).toEqual(true);
|
|
104
114
|
|
|
105
115
|
// not match
|
|
106
|
-
expect(allConditionsAreMatched(conditions, { name: "Hello World" })).toEqual(false);
|
|
107
|
-
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" })).toEqual(false);
|
|
116
|
+
expect(allConditionsAreMatched(conditions, { name: "Hello World" }, logger)).toEqual(false);
|
|
117
|
+
expect(allConditionsAreMatched(conditions, { name: "Yo! Hello!" }, logger)).toEqual(false);
|
|
108
118
|
});
|
|
109
119
|
|
|
110
120
|
it("should match with operator: in", function () {
|
|
@@ -117,12 +127,16 @@ describe("sdk: Conditions", function () {
|
|
|
117
127
|
];
|
|
118
128
|
|
|
119
129
|
// match
|
|
120
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(true);
|
|
121
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" })).toEqual(
|
|
130
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" }, logger)).toEqual(true);
|
|
131
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" }, logger)).toEqual(
|
|
132
|
+
true,
|
|
133
|
+
);
|
|
122
134
|
|
|
123
135
|
// not match
|
|
124
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "edge" })).toEqual(false);
|
|
125
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "safari" })).toEqual(
|
|
136
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "edge" }, logger)).toEqual(false);
|
|
137
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "safari" }, logger)).toEqual(
|
|
138
|
+
false,
|
|
139
|
+
);
|
|
126
140
|
});
|
|
127
141
|
|
|
128
142
|
it("should match with operator: notIn", function () {
|
|
@@ -135,12 +149,16 @@ describe("sdk: Conditions", function () {
|
|
|
135
149
|
];
|
|
136
150
|
|
|
137
151
|
// match
|
|
138
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "edge" })).toEqual(true);
|
|
139
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "safari" })).toEqual(true);
|
|
152
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "edge" }, logger)).toEqual(true);
|
|
153
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "safari" }, logger)).toEqual(true);
|
|
140
154
|
|
|
141
155
|
// not match
|
|
142
|
-
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" })).toEqual(
|
|
143
|
-
|
|
156
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "chrome" }, logger)).toEqual(
|
|
157
|
+
false,
|
|
158
|
+
);
|
|
159
|
+
expect(allConditionsAreMatched(conditions, { browser_type: "firefox" }, logger)).toEqual(
|
|
160
|
+
false,
|
|
161
|
+
);
|
|
144
162
|
});
|
|
145
163
|
|
|
146
164
|
it("should match with operator: greaterThan", function () {
|
|
@@ -153,10 +171,10 @@ describe("sdk: Conditions", function () {
|
|
|
153
171
|
];
|
|
154
172
|
|
|
155
173
|
// match
|
|
156
|
-
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(true);
|
|
174
|
+
expect(allConditionsAreMatched(conditions, { age: 19 }, logger)).toEqual(true);
|
|
157
175
|
|
|
158
176
|
// not match
|
|
159
|
-
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(false);
|
|
177
|
+
expect(allConditionsAreMatched(conditions, { age: 17 }, logger)).toEqual(false);
|
|
160
178
|
});
|
|
161
179
|
|
|
162
180
|
it("should match with operator: greaterThanOrEquals", function () {
|
|
@@ -169,12 +187,12 @@ describe("sdk: Conditions", function () {
|
|
|
169
187
|
];
|
|
170
188
|
|
|
171
189
|
// match
|
|
172
|
-
expect(allConditionsAreMatched(conditions, { age: 18 })).toEqual(true);
|
|
173
|
-
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(true);
|
|
190
|
+
expect(allConditionsAreMatched(conditions, { age: 18 }, logger)).toEqual(true);
|
|
191
|
+
expect(allConditionsAreMatched(conditions, { age: 19 }, logger)).toEqual(true);
|
|
174
192
|
|
|
175
193
|
// not match
|
|
176
|
-
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(false);
|
|
177
|
-
expect(allConditionsAreMatched(conditions, { age: 16 })).toEqual(false);
|
|
194
|
+
expect(allConditionsAreMatched(conditions, { age: 17 }, logger)).toEqual(false);
|
|
195
|
+
expect(allConditionsAreMatched(conditions, { age: 16 }, logger)).toEqual(false);
|
|
178
196
|
});
|
|
179
197
|
|
|
180
198
|
it("should match with operator: lessThan", function () {
|
|
@@ -187,10 +205,10 @@ describe("sdk: Conditions", function () {
|
|
|
187
205
|
];
|
|
188
206
|
|
|
189
207
|
// match
|
|
190
|
-
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(true);
|
|
208
|
+
expect(allConditionsAreMatched(conditions, { age: 17 }, logger)).toEqual(true);
|
|
191
209
|
|
|
192
210
|
// not match
|
|
193
|
-
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(false);
|
|
211
|
+
expect(allConditionsAreMatched(conditions, { age: 19 }, logger)).toEqual(false);
|
|
194
212
|
});
|
|
195
213
|
|
|
196
214
|
it("should match with operator: lessThanOrEquals", function () {
|
|
@@ -203,12 +221,12 @@ describe("sdk: Conditions", function () {
|
|
|
203
221
|
];
|
|
204
222
|
|
|
205
223
|
// match
|
|
206
|
-
expect(allConditionsAreMatched(conditions, { age: 17 })).toEqual(true);
|
|
207
|
-
expect(allConditionsAreMatched(conditions, { age: 18 })).toEqual(true);
|
|
224
|
+
expect(allConditionsAreMatched(conditions, { age: 17 }, logger)).toEqual(true);
|
|
225
|
+
expect(allConditionsAreMatched(conditions, { age: 18 }, logger)).toEqual(true);
|
|
208
226
|
|
|
209
227
|
// not match
|
|
210
|
-
expect(allConditionsAreMatched(conditions, { age: 19 })).toEqual(false);
|
|
211
|
-
expect(allConditionsAreMatched(conditions, { age: 20 })).toEqual(false);
|
|
228
|
+
expect(allConditionsAreMatched(conditions, { age: 19 }, logger)).toEqual(false);
|
|
229
|
+
expect(allConditionsAreMatched(conditions, { age: 20 }, logger)).toEqual(false);
|
|
212
230
|
});
|
|
213
231
|
|
|
214
232
|
it("should match with operator: semverEquals", function () {
|
|
@@ -221,10 +239,10 @@ describe("sdk: Conditions", function () {
|
|
|
221
239
|
];
|
|
222
240
|
|
|
223
241
|
// match
|
|
224
|
-
expect(allConditionsAreMatched(conditions, { version: "1.0.0" })).toEqual(true);
|
|
242
|
+
expect(allConditionsAreMatched(conditions, { version: "1.0.0" }, logger)).toEqual(true);
|
|
225
243
|
|
|
226
244
|
// not match
|
|
227
|
-
expect(allConditionsAreMatched(conditions, { version: "2.0.0" })).toEqual(false);
|
|
245
|
+
expect(allConditionsAreMatched(conditions, { version: "2.0.0" }, logger)).toEqual(false);
|
|
228
246
|
});
|
|
229
247
|
|
|
230
248
|
it("should match with operator: semverNotEquals", function () {
|
|
@@ -237,10 +255,10 @@ describe("sdk: Conditions", function () {
|
|
|
237
255
|
];
|
|
238
256
|
|
|
239
257
|
// match
|
|
240
|
-
expect(allConditionsAreMatched(conditions, { version: "2.0.0" })).toEqual(true);
|
|
258
|
+
expect(allConditionsAreMatched(conditions, { version: "2.0.0" }, logger)).toEqual(true);
|
|
241
259
|
|
|
242
260
|
// not match
|
|
243
|
-
expect(allConditionsAreMatched(conditions, { version: "1.0.0" })).toEqual(false);
|
|
261
|
+
expect(allConditionsAreMatched(conditions, { version: "1.0.0" }, logger)).toEqual(false);
|
|
244
262
|
});
|
|
245
263
|
|
|
246
264
|
it("should match with operator: semverGreaterThan", function () {
|
|
@@ -253,10 +271,10 @@ describe("sdk: Conditions", function () {
|
|
|
253
271
|
];
|
|
254
272
|
|
|
255
273
|
// match
|
|
256
|
-
expect(allConditionsAreMatched(conditions, { version: "2.0.0" })).toEqual(true);
|
|
274
|
+
expect(allConditionsAreMatched(conditions, { version: "2.0.0" }, logger)).toEqual(true);
|
|
257
275
|
|
|
258
276
|
// not match
|
|
259
|
-
expect(allConditionsAreMatched(conditions, { version: "0.9.0" })).toEqual(false);
|
|
277
|
+
expect(allConditionsAreMatched(conditions, { version: "0.9.0" }, logger)).toEqual(false);
|
|
260
278
|
});
|
|
261
279
|
|
|
262
280
|
it("should match with operator: semverGreaterThanOrEquals", function () {
|
|
@@ -269,11 +287,11 @@ describe("sdk: Conditions", function () {
|
|
|
269
287
|
];
|
|
270
288
|
|
|
271
289
|
// match
|
|
272
|
-
expect(allConditionsAreMatched(conditions, { version: "1.0.0" })).toEqual(true);
|
|
273
|
-
expect(allConditionsAreMatched(conditions, { version: "2.0.0" })).toEqual(true);
|
|
290
|
+
expect(allConditionsAreMatched(conditions, { version: "1.0.0" }, logger)).toEqual(true);
|
|
291
|
+
expect(allConditionsAreMatched(conditions, { version: "2.0.0" }, logger)).toEqual(true);
|
|
274
292
|
|
|
275
293
|
// not match
|
|
276
|
-
expect(allConditionsAreMatched(conditions, { version: "0.9.0" })).toEqual(false);
|
|
294
|
+
expect(allConditionsAreMatched(conditions, { version: "0.9.0" }, logger)).toEqual(false);
|
|
277
295
|
});
|
|
278
296
|
|
|
279
297
|
it("should match with operator: semverLessThan", function () {
|
|
@@ -286,10 +304,10 @@ describe("sdk: Conditions", function () {
|
|
|
286
304
|
];
|
|
287
305
|
|
|
288
306
|
// match
|
|
289
|
-
expect(allConditionsAreMatched(conditions, { version: "0.9.0" })).toEqual(true);
|
|
307
|
+
expect(allConditionsAreMatched(conditions, { version: "0.9.0" }, logger)).toEqual(true);
|
|
290
308
|
|
|
291
309
|
// not match
|
|
292
|
-
expect(allConditionsAreMatched(conditions, { version: "1.1.0" })).toEqual(false);
|
|
310
|
+
expect(allConditionsAreMatched(conditions, { version: "1.1.0" }, logger)).toEqual(false);
|
|
293
311
|
});
|
|
294
312
|
|
|
295
313
|
it("should match with operator: semverLessThanOrEquals", function () {
|
|
@@ -302,10 +320,10 @@ describe("sdk: Conditions", function () {
|
|
|
302
320
|
];
|
|
303
321
|
|
|
304
322
|
// match
|
|
305
|
-
expect(allConditionsAreMatched(conditions, { version: "1.0.0" })).toEqual(true);
|
|
323
|
+
expect(allConditionsAreMatched(conditions, { version: "1.0.0" }, logger)).toEqual(true);
|
|
306
324
|
|
|
307
325
|
// not match
|
|
308
|
-
expect(allConditionsAreMatched(conditions, { version: "1.1.0" })).toEqual(false);
|
|
326
|
+
expect(allConditionsAreMatched(conditions, { version: "1.1.0" }, logger)).toEqual(false);
|
|
309
327
|
});
|
|
310
328
|
|
|
311
329
|
it("should match with operator: before", function () {
|
|
@@ -318,15 +336,19 @@ describe("sdk: Conditions", function () {
|
|
|
318
336
|
];
|
|
319
337
|
|
|
320
338
|
// match
|
|
321
|
-
expect(allConditionsAreMatched(conditions, { date: "2023-05-12T00:00:00Z" })).toEqual(
|
|
339
|
+
expect(allConditionsAreMatched(conditions, { date: "2023-05-12T00:00:00Z" }, logger)).toEqual(
|
|
340
|
+
true,
|
|
341
|
+
);
|
|
322
342
|
expect(
|
|
323
|
-
allConditionsAreMatched(conditions, { date: new Date("2023-05-12T00:00:00Z") }),
|
|
343
|
+
allConditionsAreMatched(conditions, { date: new Date("2023-05-12T00:00:00Z") }, logger),
|
|
324
344
|
).toEqual(true);
|
|
325
345
|
|
|
326
346
|
// not match
|
|
327
|
-
expect(allConditionsAreMatched(conditions, { date: "2023-05-14T00:00:00Z" })).toEqual(
|
|
347
|
+
expect(allConditionsAreMatched(conditions, { date: "2023-05-14T00:00:00Z" }, logger)).toEqual(
|
|
348
|
+
false,
|
|
349
|
+
);
|
|
328
350
|
expect(
|
|
329
|
-
allConditionsAreMatched(conditions, { date: new Date("2023-05-14T00:00:00Z") }),
|
|
351
|
+
allConditionsAreMatched(conditions, { date: new Date("2023-05-14T00:00:00Z") }, logger),
|
|
330
352
|
).toEqual(false);
|
|
331
353
|
});
|
|
332
354
|
|
|
@@ -340,15 +362,19 @@ describe("sdk: Conditions", function () {
|
|
|
340
362
|
];
|
|
341
363
|
|
|
342
364
|
// match
|
|
343
|
-
expect(allConditionsAreMatched(conditions, { date: "2023-05-14T00:00:00Z" })).toEqual(
|
|
365
|
+
expect(allConditionsAreMatched(conditions, { date: "2023-05-14T00:00:00Z" }, logger)).toEqual(
|
|
366
|
+
true,
|
|
367
|
+
);
|
|
344
368
|
expect(
|
|
345
|
-
allConditionsAreMatched(conditions, { date: new Date("2023-05-14T00:00:00Z") }),
|
|
369
|
+
allConditionsAreMatched(conditions, { date: new Date("2023-05-14T00:00:00Z") }, logger),
|
|
346
370
|
).toEqual(true);
|
|
347
371
|
|
|
348
372
|
// not match
|
|
349
|
-
expect(allConditionsAreMatched(conditions, { date: "2023-05-12T00:00:00Z" })).toEqual(
|
|
373
|
+
expect(allConditionsAreMatched(conditions, { date: "2023-05-12T00:00:00Z" }, logger)).toEqual(
|
|
374
|
+
false,
|
|
375
|
+
);
|
|
350
376
|
expect(
|
|
351
|
-
allConditionsAreMatched(conditions, { date: new Date("2023-05-12T00:00:00Z") }),
|
|
377
|
+
allConditionsAreMatched(conditions, { date: new Date("2023-05-12T00:00:00Z") }, logger),
|
|
352
378
|
).toEqual(false);
|
|
353
379
|
});
|
|
354
380
|
});
|
|
@@ -365,9 +391,13 @@ describe("sdk: Conditions", function () {
|
|
|
365
391
|
|
|
366
392
|
// match
|
|
367
393
|
expect(
|
|
368
|
-
allConditionsAreMatched(
|
|
369
|
-
|
|
370
|
-
|
|
394
|
+
allConditionsAreMatched(
|
|
395
|
+
conditions[0],
|
|
396
|
+
{
|
|
397
|
+
browser_type: "chrome",
|
|
398
|
+
},
|
|
399
|
+
logger,
|
|
400
|
+
),
|
|
371
401
|
).toEqual(true);
|
|
372
402
|
});
|
|
373
403
|
|
|
@@ -382,9 +412,13 @@ describe("sdk: Conditions", function () {
|
|
|
382
412
|
|
|
383
413
|
// match
|
|
384
414
|
expect(
|
|
385
|
-
allConditionsAreMatched(
|
|
386
|
-
|
|
387
|
-
|
|
415
|
+
allConditionsAreMatched(
|
|
416
|
+
conditions,
|
|
417
|
+
{
|
|
418
|
+
browser_type: "chrome",
|
|
419
|
+
},
|
|
420
|
+
logger,
|
|
421
|
+
),
|
|
388
422
|
).toEqual(true);
|
|
389
423
|
});
|
|
390
424
|
|
|
@@ -393,16 +427,24 @@ describe("sdk: Conditions", function () {
|
|
|
393
427
|
|
|
394
428
|
// match
|
|
395
429
|
expect(
|
|
396
|
-
allConditionsAreMatched(
|
|
397
|
-
|
|
398
|
-
|
|
430
|
+
allConditionsAreMatched(
|
|
431
|
+
conditions,
|
|
432
|
+
{
|
|
433
|
+
browser_type: "chrome",
|
|
434
|
+
},
|
|
435
|
+
logger,
|
|
436
|
+
),
|
|
399
437
|
).toEqual(true);
|
|
400
438
|
|
|
401
439
|
// not match
|
|
402
440
|
expect(
|
|
403
|
-
allConditionsAreMatched(
|
|
404
|
-
|
|
405
|
-
|
|
441
|
+
allConditionsAreMatched(
|
|
442
|
+
conditions,
|
|
443
|
+
{
|
|
444
|
+
browser_type: "firefox",
|
|
445
|
+
},
|
|
446
|
+
logger,
|
|
447
|
+
),
|
|
406
448
|
).toEqual(true);
|
|
407
449
|
});
|
|
408
450
|
|
|
@@ -417,10 +459,14 @@ describe("sdk: Conditions", function () {
|
|
|
417
459
|
|
|
418
460
|
// match
|
|
419
461
|
expect(
|
|
420
|
-
allConditionsAreMatched(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
462
|
+
allConditionsAreMatched(
|
|
463
|
+
conditions,
|
|
464
|
+
{
|
|
465
|
+
browser_type: "chrome",
|
|
466
|
+
browser_version: "1.0",
|
|
467
|
+
},
|
|
468
|
+
logger,
|
|
469
|
+
),
|
|
424
470
|
).toEqual(true);
|
|
425
471
|
});
|
|
426
472
|
|
|
@@ -440,11 +486,15 @@ describe("sdk: Conditions", function () {
|
|
|
440
486
|
|
|
441
487
|
// match
|
|
442
488
|
expect(
|
|
443
|
-
allConditionsAreMatched(
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
489
|
+
allConditionsAreMatched(
|
|
490
|
+
conditions,
|
|
491
|
+
{
|
|
492
|
+
browser_type: "chrome",
|
|
493
|
+
browser_version: "1.0",
|
|
494
|
+
foo: "bar",
|
|
495
|
+
},
|
|
496
|
+
logger,
|
|
497
|
+
),
|
|
448
498
|
).toEqual(true);
|
|
449
499
|
});
|
|
450
500
|
});
|
|
@@ -465,16 +515,24 @@ describe("sdk: Conditions", function () {
|
|
|
465
515
|
|
|
466
516
|
// match
|
|
467
517
|
expect(
|
|
468
|
-
allConditionsAreMatched(
|
|
469
|
-
|
|
470
|
-
|
|
518
|
+
allConditionsAreMatched(
|
|
519
|
+
conditions,
|
|
520
|
+
{
|
|
521
|
+
browser_type: "chrome",
|
|
522
|
+
},
|
|
523
|
+
logger,
|
|
524
|
+
),
|
|
471
525
|
).toEqual(true);
|
|
472
526
|
|
|
473
527
|
// not match
|
|
474
528
|
expect(
|
|
475
|
-
allConditionsAreMatched(
|
|
476
|
-
|
|
477
|
-
|
|
529
|
+
allConditionsAreMatched(
|
|
530
|
+
conditions,
|
|
531
|
+
{
|
|
532
|
+
browser_type: "firefox",
|
|
533
|
+
},
|
|
534
|
+
logger,
|
|
535
|
+
),
|
|
478
536
|
).toEqual(false);
|
|
479
537
|
});
|
|
480
538
|
|
|
@@ -498,17 +556,25 @@ describe("sdk: Conditions", function () {
|
|
|
498
556
|
|
|
499
557
|
// match
|
|
500
558
|
expect(
|
|
501
|
-
allConditionsAreMatched(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
559
|
+
allConditionsAreMatched(
|
|
560
|
+
conditions,
|
|
561
|
+
{
|
|
562
|
+
browser_type: "chrome",
|
|
563
|
+
browser_version: "1.0",
|
|
564
|
+
},
|
|
565
|
+
logger,
|
|
566
|
+
),
|
|
505
567
|
).toEqual(true);
|
|
506
568
|
|
|
507
569
|
// not match
|
|
508
570
|
expect(
|
|
509
|
-
allConditionsAreMatched(
|
|
510
|
-
|
|
511
|
-
|
|
571
|
+
allConditionsAreMatched(
|
|
572
|
+
conditions,
|
|
573
|
+
{
|
|
574
|
+
browser_type: "chrome",
|
|
575
|
+
},
|
|
576
|
+
logger,
|
|
577
|
+
),
|
|
512
578
|
).toEqual(false);
|
|
513
579
|
});
|
|
514
580
|
});
|
|
@@ -529,9 +595,13 @@ describe("sdk: Conditions", function () {
|
|
|
529
595
|
|
|
530
596
|
// match
|
|
531
597
|
expect(
|
|
532
|
-
allConditionsAreMatched(
|
|
533
|
-
|
|
534
|
-
|
|
598
|
+
allConditionsAreMatched(
|
|
599
|
+
conditions,
|
|
600
|
+
{
|
|
601
|
+
browser_type: "chrome",
|
|
602
|
+
},
|
|
603
|
+
logger,
|
|
604
|
+
),
|
|
535
605
|
).toEqual(true);
|
|
536
606
|
});
|
|
537
607
|
|
|
@@ -555,16 +625,24 @@ describe("sdk: Conditions", function () {
|
|
|
555
625
|
|
|
556
626
|
// match
|
|
557
627
|
expect(
|
|
558
|
-
allConditionsAreMatched(
|
|
559
|
-
|
|
560
|
-
|
|
628
|
+
allConditionsAreMatched(
|
|
629
|
+
conditions,
|
|
630
|
+
{
|
|
631
|
+
browser_version: "1.0",
|
|
632
|
+
},
|
|
633
|
+
logger,
|
|
634
|
+
),
|
|
561
635
|
).toEqual(true);
|
|
562
636
|
|
|
563
637
|
// not match
|
|
564
638
|
expect(
|
|
565
|
-
allConditionsAreMatched(
|
|
566
|
-
|
|
567
|
-
|
|
639
|
+
allConditionsAreMatched(
|
|
640
|
+
conditions,
|
|
641
|
+
{
|
|
642
|
+
browser_type: "firefox",
|
|
643
|
+
},
|
|
644
|
+
logger,
|
|
645
|
+
),
|
|
568
646
|
).toEqual(false);
|
|
569
647
|
});
|
|
570
648
|
});
|
|
@@ -585,16 +663,24 @@ describe("sdk: Conditions", function () {
|
|
|
585
663
|
|
|
586
664
|
// match
|
|
587
665
|
expect(
|
|
588
|
-
allConditionsAreMatched(
|
|
589
|
-
|
|
590
|
-
|
|
666
|
+
allConditionsAreMatched(
|
|
667
|
+
conditions,
|
|
668
|
+
{
|
|
669
|
+
browser_type: "firefox",
|
|
670
|
+
},
|
|
671
|
+
logger,
|
|
672
|
+
),
|
|
591
673
|
).toEqual(true);
|
|
592
674
|
|
|
593
675
|
// not match
|
|
594
676
|
expect(
|
|
595
|
-
allConditionsAreMatched(
|
|
596
|
-
|
|
597
|
-
|
|
677
|
+
allConditionsAreMatched(
|
|
678
|
+
conditions,
|
|
679
|
+
{
|
|
680
|
+
browser_type: "chrome",
|
|
681
|
+
},
|
|
682
|
+
logger,
|
|
683
|
+
),
|
|
598
684
|
).toEqual(false);
|
|
599
685
|
});
|
|
600
686
|
|
|
@@ -618,29 +704,45 @@ describe("sdk: Conditions", function () {
|
|
|
618
704
|
|
|
619
705
|
// match
|
|
620
706
|
expect(
|
|
621
|
-
allConditionsAreMatched(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
707
|
+
allConditionsAreMatched(
|
|
708
|
+
conditions,
|
|
709
|
+
{
|
|
710
|
+
browser_type: "firefox",
|
|
711
|
+
browser_version: "2.0",
|
|
712
|
+
},
|
|
713
|
+
logger,
|
|
714
|
+
),
|
|
625
715
|
).toEqual(true);
|
|
626
716
|
expect(
|
|
627
|
-
allConditionsAreMatched(
|
|
628
|
-
|
|
629
|
-
|
|
717
|
+
allConditionsAreMatched(
|
|
718
|
+
conditions,
|
|
719
|
+
{
|
|
720
|
+
browser_type: "chrome",
|
|
721
|
+
},
|
|
722
|
+
logger,
|
|
723
|
+
),
|
|
630
724
|
).toEqual(true);
|
|
631
725
|
expect(
|
|
632
|
-
allConditionsAreMatched(
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
726
|
+
allConditionsAreMatched(
|
|
727
|
+
conditions,
|
|
728
|
+
{
|
|
729
|
+
browser_type: "chrome",
|
|
730
|
+
browser_version: "2.0",
|
|
731
|
+
},
|
|
732
|
+
logger,
|
|
733
|
+
),
|
|
636
734
|
).toEqual(true);
|
|
637
735
|
|
|
638
736
|
// not match
|
|
639
737
|
expect(
|
|
640
|
-
allConditionsAreMatched(
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
738
|
+
allConditionsAreMatched(
|
|
739
|
+
conditions,
|
|
740
|
+
{
|
|
741
|
+
browser_type: "chrome",
|
|
742
|
+
browser_version: "1.0",
|
|
743
|
+
},
|
|
744
|
+
logger,
|
|
745
|
+
),
|
|
644
746
|
).toEqual(false);
|
|
645
747
|
});
|
|
646
748
|
});
|
|
@@ -675,31 +777,47 @@ describe("sdk: Conditions", function () {
|
|
|
675
777
|
|
|
676
778
|
// match
|
|
677
779
|
expect(
|
|
678
|
-
allConditionsAreMatched(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
780
|
+
allConditionsAreMatched(
|
|
781
|
+
conditions,
|
|
782
|
+
{
|
|
783
|
+
browser_type: "chrome",
|
|
784
|
+
browser_version: "1.0",
|
|
785
|
+
},
|
|
786
|
+
logger,
|
|
787
|
+
),
|
|
682
788
|
).toEqual(true);
|
|
683
789
|
|
|
684
790
|
expect(
|
|
685
|
-
allConditionsAreMatched(
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
791
|
+
allConditionsAreMatched(
|
|
792
|
+
conditions,
|
|
793
|
+
{
|
|
794
|
+
browser_type: "chrome",
|
|
795
|
+
browser_version: "2.0",
|
|
796
|
+
},
|
|
797
|
+
logger,
|
|
798
|
+
),
|
|
689
799
|
).toEqual(true);
|
|
690
800
|
|
|
691
801
|
// not match
|
|
692
802
|
expect(
|
|
693
|
-
allConditionsAreMatched(
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
803
|
+
allConditionsAreMatched(
|
|
804
|
+
conditions,
|
|
805
|
+
{
|
|
806
|
+
browser_type: "chrome",
|
|
807
|
+
browser_version: "3.0",
|
|
808
|
+
},
|
|
809
|
+
logger,
|
|
810
|
+
),
|
|
697
811
|
).toEqual(false);
|
|
698
812
|
|
|
699
813
|
expect(
|
|
700
|
-
allConditionsAreMatched(
|
|
701
|
-
|
|
702
|
-
|
|
814
|
+
allConditionsAreMatched(
|
|
815
|
+
conditions,
|
|
816
|
+
{
|
|
817
|
+
browser_version: "2.0",
|
|
818
|
+
},
|
|
819
|
+
logger,
|
|
820
|
+
),
|
|
703
821
|
).toEqual(false);
|
|
704
822
|
});
|
|
705
823
|
|
|
@@ -737,34 +855,50 @@ describe("sdk: Conditions", function () {
|
|
|
737
855
|
|
|
738
856
|
// match
|
|
739
857
|
expect(
|
|
740
|
-
allConditionsAreMatched(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
858
|
+
allConditionsAreMatched(
|
|
859
|
+
conditions,
|
|
860
|
+
{
|
|
861
|
+
country: "nl",
|
|
862
|
+
browser_type: "chrome",
|
|
863
|
+
browser_version: "1.0",
|
|
864
|
+
},
|
|
865
|
+
logger,
|
|
866
|
+
),
|
|
745
867
|
).toEqual(true);
|
|
746
868
|
|
|
747
869
|
expect(
|
|
748
|
-
allConditionsAreMatched(
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
870
|
+
allConditionsAreMatched(
|
|
871
|
+
conditions,
|
|
872
|
+
{
|
|
873
|
+
country: "nl",
|
|
874
|
+
browser_type: "chrome",
|
|
875
|
+
browser_version: "2.0",
|
|
876
|
+
},
|
|
877
|
+
logger,
|
|
878
|
+
),
|
|
753
879
|
).toEqual(true);
|
|
754
880
|
|
|
755
881
|
// not match
|
|
756
882
|
expect(
|
|
757
|
-
allConditionsAreMatched(
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
883
|
+
allConditionsAreMatched(
|
|
884
|
+
conditions,
|
|
885
|
+
{
|
|
886
|
+
browser_type: "chrome",
|
|
887
|
+
browser_version: "3.0",
|
|
888
|
+
},
|
|
889
|
+
logger,
|
|
890
|
+
),
|
|
761
891
|
).toEqual(false);
|
|
762
892
|
|
|
763
893
|
expect(
|
|
764
|
-
allConditionsAreMatched(
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
894
|
+
allConditionsAreMatched(
|
|
895
|
+
conditions,
|
|
896
|
+
{
|
|
897
|
+
country: "us",
|
|
898
|
+
browser_version: "2.0",
|
|
899
|
+
},
|
|
900
|
+
logger,
|
|
901
|
+
),
|
|
768
902
|
).toEqual(false);
|
|
769
903
|
});
|
|
770
904
|
|
|
@@ -797,33 +931,49 @@ describe("sdk: Conditions", function () {
|
|
|
797
931
|
|
|
798
932
|
// match
|
|
799
933
|
expect(
|
|
800
|
-
allConditionsAreMatched(
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
934
|
+
allConditionsAreMatched(
|
|
935
|
+
conditions,
|
|
936
|
+
{
|
|
937
|
+
browser_type: "chrome",
|
|
938
|
+
browser_version: "2.0",
|
|
939
|
+
},
|
|
940
|
+
logger,
|
|
941
|
+
),
|
|
804
942
|
).toEqual(true);
|
|
805
943
|
|
|
806
944
|
expect(
|
|
807
|
-
allConditionsAreMatched(
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
945
|
+
allConditionsAreMatched(
|
|
946
|
+
conditions,
|
|
947
|
+
{
|
|
948
|
+
browser_type: "firefox",
|
|
949
|
+
device_type: "mobile",
|
|
950
|
+
orientation: "portrait",
|
|
951
|
+
},
|
|
952
|
+
logger,
|
|
953
|
+
),
|
|
812
954
|
).toEqual(true);
|
|
813
955
|
|
|
814
956
|
// not match
|
|
815
957
|
expect(
|
|
816
|
-
allConditionsAreMatched(
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
958
|
+
allConditionsAreMatched(
|
|
959
|
+
conditions,
|
|
960
|
+
{
|
|
961
|
+
browser_type: "firefox",
|
|
962
|
+
browser_version: "2.0",
|
|
963
|
+
},
|
|
964
|
+
logger,
|
|
965
|
+
),
|
|
820
966
|
).toEqual(false);
|
|
821
967
|
|
|
822
968
|
expect(
|
|
823
|
-
allConditionsAreMatched(
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
969
|
+
allConditionsAreMatched(
|
|
970
|
+
conditions,
|
|
971
|
+
{
|
|
972
|
+
browser_type: "firefox",
|
|
973
|
+
device_type: "desktop",
|
|
974
|
+
},
|
|
975
|
+
logger,
|
|
976
|
+
),
|
|
827
977
|
).toEqual(false);
|
|
828
978
|
});
|
|
829
979
|
|
|
@@ -861,36 +1011,52 @@ describe("sdk: Conditions", function () {
|
|
|
861
1011
|
|
|
862
1012
|
// match
|
|
863
1013
|
expect(
|
|
864
|
-
allConditionsAreMatched(
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1014
|
+
allConditionsAreMatched(
|
|
1015
|
+
conditions,
|
|
1016
|
+
{
|
|
1017
|
+
country: "nl",
|
|
1018
|
+
browser_type: "chrome",
|
|
1019
|
+
browser_version: "2.0",
|
|
1020
|
+
},
|
|
1021
|
+
logger,
|
|
1022
|
+
),
|
|
869
1023
|
).toEqual(true);
|
|
870
1024
|
|
|
871
1025
|
expect(
|
|
872
|
-
allConditionsAreMatched(
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
1026
|
+
allConditionsAreMatched(
|
|
1027
|
+
conditions,
|
|
1028
|
+
{
|
|
1029
|
+
country: "nl",
|
|
1030
|
+
browser_type: "firefox",
|
|
1031
|
+
device_type: "mobile",
|
|
1032
|
+
orientation: "portrait",
|
|
1033
|
+
},
|
|
1034
|
+
logger,
|
|
1035
|
+
),
|
|
878
1036
|
).toEqual(true);
|
|
879
1037
|
|
|
880
1038
|
// not match
|
|
881
1039
|
expect(
|
|
882
|
-
allConditionsAreMatched(
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
1040
|
+
allConditionsAreMatched(
|
|
1041
|
+
conditions,
|
|
1042
|
+
{
|
|
1043
|
+
browser_type: "firefox",
|
|
1044
|
+
browser_version: "2.0",
|
|
1045
|
+
},
|
|
1046
|
+
logger,
|
|
1047
|
+
),
|
|
886
1048
|
).toEqual(false);
|
|
887
1049
|
|
|
888
1050
|
expect(
|
|
889
|
-
allConditionsAreMatched(
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1051
|
+
allConditionsAreMatched(
|
|
1052
|
+
conditions,
|
|
1053
|
+
{
|
|
1054
|
+
country: "de",
|
|
1055
|
+
browser_type: "firefox",
|
|
1056
|
+
device_type: "desktop",
|
|
1057
|
+
},
|
|
1058
|
+
logger,
|
|
1059
|
+
),
|
|
894
1060
|
).toEqual(false);
|
|
895
1061
|
});
|
|
896
1062
|
});
|