@featurevisor/sdk 0.48.0 → 0.50.0

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.
@@ -1204,4 +1204,69 @@ describe("sdk: instance", function () {
1204
1204
  // disabled
1205
1205
  expect(sdk.getVariable("test", "color", { userId: "user-gb" })).toEqual(undefined);
1206
1206
  });
1207
+
1208
+ it("should check if enabled for individually named segments", function () {
1209
+ const sdk = createInstance({
1210
+ datafile: {
1211
+ schemaVersion: "1",
1212
+ revision: "1.0",
1213
+ features: [
1214
+ {
1215
+ key: "test",
1216
+ bucketBy: "userId",
1217
+ traffic: [
1218
+ { key: "1", segments: "netherlands", percentage: 100000, allocation: [] },
1219
+ {
1220
+ key: "2",
1221
+ segments: JSON.stringify(["iphone", "unitedStates"]),
1222
+ percentage: 100000,
1223
+ allocation: [],
1224
+ },
1225
+ ],
1226
+ },
1227
+ ],
1228
+ attributes: [],
1229
+ segments: [
1230
+ {
1231
+ key: "netherlands",
1232
+ conditions: JSON.stringify([
1233
+ {
1234
+ attribute: "country",
1235
+ operator: "equals",
1236
+ value: "nl",
1237
+ },
1238
+ ]),
1239
+ },
1240
+ {
1241
+ key: "iphone",
1242
+ conditions: JSON.stringify([
1243
+ {
1244
+ attribute: "device",
1245
+ operator: "equals",
1246
+ value: "iphone",
1247
+ },
1248
+ ]),
1249
+ },
1250
+ {
1251
+ key: "unitedStates",
1252
+ conditions: JSON.stringify([
1253
+ {
1254
+ attribute: "country",
1255
+ operator: "equals",
1256
+ value: "us",
1257
+ },
1258
+ ]),
1259
+ },
1260
+ ],
1261
+ },
1262
+ });
1263
+
1264
+ expect(sdk.isEnabled("test")).toEqual(false);
1265
+ expect(sdk.isEnabled("test", { userId: "123" })).toEqual(false);
1266
+ expect(sdk.isEnabled("test", { userId: "123", country: "de" })).toEqual(false);
1267
+ expect(sdk.isEnabled("test", { userId: "123", country: "us" })).toEqual(false);
1268
+
1269
+ expect(sdk.isEnabled("test", { userId: "123", country: "nl" })).toEqual(true);
1270
+ expect(sdk.isEnabled("test", { userId: "123", country: "us", device: "iphone" })).toEqual(true);
1271
+ });
1207
1272
  });