@featurevisor/sdk 0.47.2 → 0.47.3

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.
@@ -41,6 +41,29 @@ describe("sdk: Segments", function () {
41
41
  and: ["netherlands", { or: ["mobileUsers", "desktopUsers"] }],
42
42
  },
43
43
  },
44
+
45
+ // german
46
+ {
47
+ key: "germanMobileUsers",
48
+ segments: [
49
+ {
50
+ and: ["mobileUsers", "germany"],
51
+ },
52
+ ],
53
+ },
54
+ {
55
+ key: "germanNonMobileUsers",
56
+ segments: [
57
+ {
58
+ and: [
59
+ "germany",
60
+ {
61
+ not: ["mobileUsers"],
62
+ },
63
+ ],
64
+ },
65
+ ],
66
+ },
44
67
  ];
45
68
 
46
69
  const datafileContent: DatafileContent = {
@@ -192,5 +215,167 @@ describe("sdk: Segments", function () {
192
215
  ),
193
216
  ).toEqual(false);
194
217
  });
218
+
219
+ it("should match dutchMobileOrDesktopUsers", function () {
220
+ const group = groups.find((g) => g.key === "dutchMobileOrDesktopUsers") as Group;
221
+
222
+ // match
223
+ expect(
224
+ allGroupSegmentsAreMatched(
225
+ group.segments,
226
+ { country: "nl", deviceType: "mobile" },
227
+ datafileReader,
228
+ ),
229
+ ).toEqual(true);
230
+ expect(
231
+ allGroupSegmentsAreMatched(
232
+ group.segments,
233
+ { country: "nl", deviceType: "mobile", browser: "chrome" },
234
+ datafileReader,
235
+ ),
236
+ ).toEqual(true);
237
+ expect(
238
+ allGroupSegmentsAreMatched(
239
+ group.segments,
240
+ { country: "nl", deviceType: "desktop" },
241
+ datafileReader,
242
+ ),
243
+ ).toEqual(true);
244
+ expect(
245
+ allGroupSegmentsAreMatched(
246
+ group.segments,
247
+ { country: "nl", deviceType: "desktop", browser: "chrome" },
248
+ datafileReader,
249
+ ),
250
+ ).toEqual(true);
251
+
252
+ // not match
253
+ expect(allGroupSegmentsAreMatched(group.segments, {}, datafileReader)).toEqual(false);
254
+ expect(
255
+ allGroupSegmentsAreMatched(
256
+ group.segments,
257
+ { country: "de", deviceType: "mobile" },
258
+ datafileReader,
259
+ ),
260
+ ).toEqual(false);
261
+ expect(
262
+ allGroupSegmentsAreMatched(
263
+ group.segments,
264
+ { country: "de", deviceType: "desktop" },
265
+ datafileReader,
266
+ ),
267
+ ).toEqual(false);
268
+ });
269
+
270
+ it("should match dutchMobileOrDesktopUsers2", function () {
271
+ const group = groups.find((g) => g.key === "dutchMobileOrDesktopUsers2") as Group;
272
+
273
+ // match
274
+ expect(
275
+ allGroupSegmentsAreMatched(
276
+ group.segments,
277
+ { country: "nl", deviceType: "mobile" },
278
+ datafileReader,
279
+ ),
280
+ ).toEqual(true);
281
+ expect(
282
+ allGroupSegmentsAreMatched(
283
+ group.segments,
284
+ { country: "nl", deviceType: "mobile", browser: "chrome" },
285
+ datafileReader,
286
+ ),
287
+ ).toEqual(true);
288
+ expect(
289
+ allGroupSegmentsAreMatched(
290
+ group.segments,
291
+ { country: "nl", deviceType: "desktop" },
292
+ datafileReader,
293
+ ),
294
+ ).toEqual(true);
295
+ expect(
296
+ allGroupSegmentsAreMatched(
297
+ group.segments,
298
+ { country: "nl", deviceType: "desktop", browser: "chrome" },
299
+ datafileReader,
300
+ ),
301
+ ).toEqual(true);
302
+
303
+ // not match
304
+ expect(allGroupSegmentsAreMatched(group.segments, {}, datafileReader)).toEqual(false);
305
+ expect(
306
+ allGroupSegmentsAreMatched(
307
+ group.segments,
308
+ { country: "de", deviceType: "mobile" },
309
+ datafileReader,
310
+ ),
311
+ ).toEqual(false);
312
+ expect(
313
+ allGroupSegmentsAreMatched(
314
+ group.segments,
315
+ { country: "de", deviceType: "desktop" },
316
+ datafileReader,
317
+ ),
318
+ ).toEqual(false);
319
+ });
320
+
321
+ it("should match germanMobileUsers", function () {
322
+ const group = groups.find((g) => g.key === "germanMobileUsers") as Group;
323
+
324
+ // match
325
+ expect(
326
+ allGroupSegmentsAreMatched(
327
+ group.segments,
328
+ { country: "de", deviceType: "mobile" },
329
+ datafileReader,
330
+ ),
331
+ ).toEqual(true);
332
+ expect(
333
+ allGroupSegmentsAreMatched(
334
+ group.segments,
335
+ { country: "de", deviceType: "mobile", browser: "chrome" },
336
+ datafileReader,
337
+ ),
338
+ ).toEqual(true);
339
+
340
+ // not match
341
+ expect(allGroupSegmentsAreMatched(group.segments, {}, datafileReader)).toEqual(false);
342
+ expect(
343
+ allGroupSegmentsAreMatched(
344
+ group.segments,
345
+ { country: "nl", deviceType: "mobile" },
346
+ datafileReader,
347
+ ),
348
+ ).toEqual(false);
349
+ });
350
+
351
+ it("should match germanNonMobileUsers", function () {
352
+ const group = groups.find((g) => g.key === "germanNonMobileUsers") as Group;
353
+
354
+ // match
355
+ expect(
356
+ allGroupSegmentsAreMatched(
357
+ group.segments,
358
+ { country: "de", deviceType: "desktop" },
359
+ datafileReader,
360
+ ),
361
+ ).toEqual(true);
362
+ expect(
363
+ allGroupSegmentsAreMatched(
364
+ group.segments,
365
+ { country: "de", deviceType: "desktop", browser: "chrome" },
366
+ datafileReader,
367
+ ),
368
+ ).toEqual(true);
369
+
370
+ // not match
371
+ expect(allGroupSegmentsAreMatched(group.segments, {}, datafileReader)).toEqual(false);
372
+ expect(
373
+ allGroupSegmentsAreMatched(
374
+ group.segments,
375
+ { country: "nl", deviceType: "desktop" },
376
+ datafileReader,
377
+ ),
378
+ ).toEqual(false);
379
+ });
195
380
  });
196
381
  });