@featurevisor/sdk 0.55.0 → 0.56.2

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.
@@ -1205,6 +1205,80 @@ describe("sdk: instance", function () {
1205
1205
  expect(sdk.getVariable("test", "color", { userId: "user-gb" })).toEqual(undefined);
1206
1206
  });
1207
1207
 
1208
+ it("should get variables without any variations", function () {
1209
+ const sdk = createInstance({
1210
+ datafile: {
1211
+ schemaVersion: "1",
1212
+ revision: "1.0",
1213
+ attributes: [
1214
+ { key: "userId", type: "string", capture: true },
1215
+ { key: "country", type: "string" },
1216
+ ],
1217
+ segments: [
1218
+ {
1219
+ key: "netherlands",
1220
+ conditions: JSON.stringify([
1221
+ {
1222
+ attribute: "country",
1223
+ operator: "equals",
1224
+ value: "nl",
1225
+ },
1226
+ ]),
1227
+ },
1228
+ ],
1229
+ features: [
1230
+ {
1231
+ key: "test",
1232
+ bucketBy: "userId",
1233
+ variablesSchema: [
1234
+ {
1235
+ key: "color",
1236
+ type: "string",
1237
+ defaultValue: "red",
1238
+ },
1239
+ ],
1240
+ traffic: [
1241
+ {
1242
+ key: "1",
1243
+ segments: "netherlands",
1244
+ percentage: 100000,
1245
+ variables: {
1246
+ color: "orange",
1247
+ },
1248
+ allocation: [],
1249
+ },
1250
+ {
1251
+ key: "2",
1252
+ segments: "*",
1253
+ percentage: 100000,
1254
+ allocation: [],
1255
+ },
1256
+ ],
1257
+ },
1258
+ ],
1259
+ },
1260
+ });
1261
+
1262
+ const defaultContext = {
1263
+ userId: "123",
1264
+ };
1265
+
1266
+ // test default value
1267
+ expect(
1268
+ sdk.getVariable("test", "color", {
1269
+ ...defaultContext,
1270
+ }),
1271
+ ).toEqual("red");
1272
+
1273
+ // test override
1274
+ expect(
1275
+ sdk.getVariable("test", "color", {
1276
+ ...defaultContext,
1277
+ country: "nl",
1278
+ }),
1279
+ ).toEqual("orange");
1280
+ });
1281
+
1208
1282
  it("should check if enabled for individually named segments", function () {
1209
1283
  const sdk = createInstance({
1210
1284
  datafile: {