@featurevisor/sdk 0.48.0 → 0.49.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.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +11 -0
- package/coverage/clover.xml +139 -136
- package/coverage/coverage-final.json +8 -8
- package/coverage/lcov-report/bucket.ts.html +4 -4
- package/coverage/lcov-report/conditions.ts.html +11 -11
- package/coverage/lcov-report/datafileReader.ts.html +16 -16
- package/coverage/lcov-report/emitter.ts.html +2 -2
- package/coverage/lcov-report/feature.ts.html +29 -29
- package/coverage/lcov-report/index.html +18 -18
- package/coverage/lcov-report/instance.ts.html +76 -76
- package/coverage/lcov-report/logger.ts.html +6 -6
- package/coverage/lcov-report/segments.ts.html +14 -14
- package/coverage/lcov.info +232 -231
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/lib/feature.js +8 -2
- package/lib/feature.js.map +1 -1
- package/package.json +3 -3
- package/src/feature.ts +10 -10
- package/src/instance.spec.ts +65 -0
package/src/instance.spec.ts
CHANGED
|
@@ -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
|
});
|