@featurevisor/sdk 0.46.1 → 0.46.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.
- package/CHANGELOG.md +8 -0
- package/coverage/clover.xml +202 -202
- package/coverage/coverage-final.json +7 -7
- package/coverage/lcov-report/bucket.ts.html +4 -4
- package/coverage/lcov-report/conditions.ts.html +1 -1
- package/coverage/lcov-report/datafileReader.ts.html +9 -9
- package/coverage/lcov-report/emitter.ts.html +22 -22
- package/coverage/lcov-report/feature.ts.html +16 -16
- package/coverage/lcov-report/index.html +28 -28
- package/coverage/lcov-report/instance.ts.html +235 -235
- package/coverage/lcov-report/logger.ts.html +8 -8
- package/coverage/lcov-report/segments.ts.html +3 -3
- package/coverage/lcov.info +331 -331
- package/dist/index.js.gz +0 -0
- package/package.json +2 -2
- package/src/instance.spec.ts +130 -3
package/dist/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featurevisor/sdk",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.2",
|
|
4
4
|
"description": "Featurevisor SDK for Node.js and the browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"compare-versions": "^6.0.0-rc.1",
|
|
47
47
|
"murmurhash": "^2.0.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "a99373ed8e07ad7ab3e284d01307fe7f2b380648"
|
|
50
50
|
}
|
package/src/instance.spec.ts
CHANGED
|
@@ -314,7 +314,8 @@ describe("sdk: instance", function () {
|
|
|
314
314
|
it("should refresh datafile", function (done) {
|
|
315
315
|
let revision = 1;
|
|
316
316
|
let refreshed = false;
|
|
317
|
-
let
|
|
317
|
+
let updatedViaOption = false;
|
|
318
|
+
let updatedViaEventListener = false;
|
|
318
319
|
|
|
319
320
|
function getDatafileContent(): DatafileContent {
|
|
320
321
|
const content: DatafileContent = {
|
|
@@ -359,15 +360,24 @@ describe("sdk: instance", function () {
|
|
|
359
360
|
refreshed = true;
|
|
360
361
|
},
|
|
361
362
|
onUpdate() {
|
|
362
|
-
|
|
363
|
+
updatedViaOption = true;
|
|
363
364
|
},
|
|
364
365
|
});
|
|
365
366
|
|
|
367
|
+
const onUpdateCallback = function () {
|
|
368
|
+
updatedViaEventListener = true;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
sdk.on("update", onUpdateCallback);
|
|
372
|
+
|
|
366
373
|
expect(sdk.isReady()).toEqual(false);
|
|
367
374
|
|
|
368
375
|
setTimeout(function () {
|
|
369
376
|
expect(refreshed).toEqual(true);
|
|
370
|
-
expect(
|
|
377
|
+
expect(updatedViaOption).toEqual(true);
|
|
378
|
+
expect(updatedViaEventListener).toEqual(true);
|
|
379
|
+
|
|
380
|
+
sdk.off("update", onUpdateCallback);
|
|
371
381
|
|
|
372
382
|
expect(sdk.isReady()).toEqual(true);
|
|
373
383
|
|
|
@@ -754,4 +764,121 @@ describe("sdk: instance", function () {
|
|
|
754
764
|
expect(deprecatedTestVariation).toEqual("control");
|
|
755
765
|
expect(deprecatedCount).toEqual(1);
|
|
756
766
|
});
|
|
767
|
+
|
|
768
|
+
it("should get variable", function () {
|
|
769
|
+
const sdk = createInstance({
|
|
770
|
+
datafile: {
|
|
771
|
+
schemaVersion: "1",
|
|
772
|
+
revision: "1.0",
|
|
773
|
+
features: [
|
|
774
|
+
{
|
|
775
|
+
key: "test",
|
|
776
|
+
bucketBy: "userId",
|
|
777
|
+
variablesSchema: [
|
|
778
|
+
{
|
|
779
|
+
key: "color",
|
|
780
|
+
type: "string",
|
|
781
|
+
defaultValue: "red",
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
key: "showSidebar",
|
|
785
|
+
type: "boolean",
|
|
786
|
+
defaultValue: false,
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
key: "count",
|
|
790
|
+
type: "integer",
|
|
791
|
+
defaultValue: 0,
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
key: "paymentMethods",
|
|
795
|
+
type: "array",
|
|
796
|
+
defaultValue: ["paypal", "creditcard"],
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
key: "flatConfig",
|
|
800
|
+
type: "object",
|
|
801
|
+
defaultValue: {
|
|
802
|
+
key: "value",
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
key: "nestedConfig",
|
|
807
|
+
type: "json",
|
|
808
|
+
defaultValue: JSON.stringify({
|
|
809
|
+
key: {
|
|
810
|
+
nested: "value",
|
|
811
|
+
},
|
|
812
|
+
}),
|
|
813
|
+
},
|
|
814
|
+
],
|
|
815
|
+
variations: [
|
|
816
|
+
{ value: "control" },
|
|
817
|
+
{
|
|
818
|
+
value: "treatment",
|
|
819
|
+
variables: [
|
|
820
|
+
{
|
|
821
|
+
key: "showSidebar",
|
|
822
|
+
value: true,
|
|
823
|
+
},
|
|
824
|
+
],
|
|
825
|
+
},
|
|
826
|
+
],
|
|
827
|
+
traffic: [
|
|
828
|
+
{
|
|
829
|
+
key: "1",
|
|
830
|
+
segments: "*",
|
|
831
|
+
percentage: 100000,
|
|
832
|
+
allocation: [
|
|
833
|
+
{ variation: "control", range: [0, 0] },
|
|
834
|
+
{ variation: "treatment", range: [0, 100000] },
|
|
835
|
+
],
|
|
836
|
+
},
|
|
837
|
+
],
|
|
838
|
+
},
|
|
839
|
+
],
|
|
840
|
+
attributes: [],
|
|
841
|
+
segments: [],
|
|
842
|
+
},
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
const context = {
|
|
846
|
+
userId: "123",
|
|
847
|
+
};
|
|
848
|
+
|
|
849
|
+
expect(sdk.getVariation("test", context)).toEqual("treatment");
|
|
850
|
+
|
|
851
|
+
expect(sdk.getVariable("test", "color", context)).toEqual("red");
|
|
852
|
+
expect(sdk.getVariableString("test", "color", context)).toEqual("red");
|
|
853
|
+
|
|
854
|
+
expect(sdk.getVariable("test", "showSidebar", context)).toEqual(true);
|
|
855
|
+
expect(sdk.getVariableBoolean("test", "showSidebar", context)).toEqual(true);
|
|
856
|
+
|
|
857
|
+
expect(sdk.getVariable("test", "count", context)).toEqual(0);
|
|
858
|
+
expect(sdk.getVariableInteger("test", "count", context)).toEqual(0);
|
|
859
|
+
|
|
860
|
+
expect(sdk.getVariable("test", "paymentMethods", context)).toEqual(["paypal", "creditcard"]);
|
|
861
|
+
expect(sdk.getVariableArray("test", "paymentMethods", context)).toEqual([
|
|
862
|
+
"paypal",
|
|
863
|
+
"creditcard",
|
|
864
|
+
]);
|
|
865
|
+
|
|
866
|
+
expect(sdk.getVariable("test", "flatConfig", context)).toEqual({
|
|
867
|
+
key: "value",
|
|
868
|
+
});
|
|
869
|
+
expect(sdk.getVariableObject("test", "flatConfig", context)).toEqual({
|
|
870
|
+
key: "value",
|
|
871
|
+
});
|
|
872
|
+
|
|
873
|
+
expect(sdk.getVariable("test", "nestedConfig", context)).toEqual({
|
|
874
|
+
key: {
|
|
875
|
+
nested: "value",
|
|
876
|
+
},
|
|
877
|
+
});
|
|
878
|
+
expect(sdk.getVariableJSON("test", "nestedConfig", context)).toEqual({
|
|
879
|
+
key: {
|
|
880
|
+
nested: "value",
|
|
881
|
+
},
|
|
882
|
+
});
|
|
883
|
+
});
|
|
757
884
|
});
|