Skip to content

Commit

Permalink
Variation Id tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lajos88 committed Nov 29, 2019
1 parent 5d56f00 commit 1142e76
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
3 changes: 2 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = function(config) {
],

preprocessors: {
"**/*.ts": ["karma-typescript"]
"src/**/*.ts": ["karma-typescript"],
"test/**/*.ts": ["karma-typescript"]
},

coverageReporter: {
Expand Down
70 changes: 70 additions & 0 deletions test/IntegrationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,74 @@ describe("Integration - ConfigCatClient", () => {
'keySampleText'
]);
});

it("Auto poll - getVariationId() works", (done) => {

const defaultValue: string = "NOT_CAT";

clientAutoPoll.getVariationId("stringDefaultCat", defaultValue, actual => {
assert.strictEqual(actual, "stringDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882");

clientAutoPoll.getVariationId("boolDefaultTrue", defaultValue, actual => {
assert.strictEqual(actual, "boolDefaultTrue-true");
done();
});
});
});

it("Auto poll - getVariationId() works", async () => {

const defaultValue: string = "NOT_CAT";

let actual = await clientAutoPoll.getVariationIdAsync("stringDefaultCat", defaultValue);
assert.strictEqual(actual, "stringDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882");

actual = await clientAutoPoll.getVariationIdAsync("boolDefaultTrue", defaultValue);
assert.strictEqual(actual, "boolDefaultTrue-true");
});

it("Auto poll - getVariationIds() works", async () => {

let actual = await clientAutoPoll.getAllVariationIds(actual => {
assert.equal(actual.length, 16);
assert.strictEqual(actual[0], 'stringDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[1], 'stringIsInDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[2], 'stringIsNotInDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[3], 'stringContainsDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[4], 'stringNotContainsDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[5], 'string25Cat25Dog25Falcon25Horse-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[6], 'string75Cat0Dog25Falcon0Horse-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[7], 'string25Cat25Dog25Falcon25HorseAdvancedRules-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[8], 'boolDefaultTrue-true');
assert.strictEqual(actual[9], 'boolDefaultFalse-false');
assert.strictEqual(actual[10], 'bool30TrueAdvancedRules-true');
assert.strictEqual(actual[11], 'integer25One25Two25Three25FourAdvancedRules-37ad889a1a0b1d6edcd4f0ae078e2889fe6cfd77');
assert.strictEqual(actual[12], 'integerDefaultOne-356a192b7913b04c54574d18c28d46e6395428ab');
assert.strictEqual(actual[13], 'doubleDefaultPi-b172eb28cfa25290f165d15f79f558d926d85d11');
assert.strictEqual(actual[14], 'double25Pi25E25Gr25Zero-37ad889a1a0b1d6edcd4f0ae078e2889fe6cfd77');
assert.strictEqual(actual[15], 'keySampleText-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
});
});

it("Auto poll - getVariationIdsAsync() works", async () => {

let actual = await clientAutoPoll.getAllVariationIdsAsync();
assert.equal(actual.length, 16);
assert.strictEqual(actual[0], 'stringDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[1], 'stringIsInDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[2], 'stringIsNotInDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[3], 'stringContainsDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[4], 'stringNotContainsDogDefaultCat-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
assert.strictEqual(actual[5], 'string25Cat25Dog25Falcon25Horse-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[6], 'string75Cat0Dog25Falcon0Horse-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[7], 'string25Cat25Dog25Falcon25HorseAdvancedRules-baaa18844b8db958c57edddf824f4a8b5cd9e298');
assert.strictEqual(actual[8], 'boolDefaultTrue-true');
assert.strictEqual(actual[9], 'boolDefaultFalse-false');
assert.strictEqual(actual[10], 'bool30TrueAdvancedRules-true');
assert.strictEqual(actual[11], 'integer25One25Two25Three25FourAdvancedRules-37ad889a1a0b1d6edcd4f0ae078e2889fe6cfd77');
assert.strictEqual(actual[12], 'integerDefaultOne-356a192b7913b04c54574d18c28d46e6395428ab');
assert.strictEqual(actual[13], 'doubleDefaultPi-b172eb28cfa25290f165d15f79f558d926d85d11');
assert.strictEqual(actual[14], 'double25Pi25E25Gr25Zero-37ad889a1a0b1d6edcd4f0ae078e2889fe6cfd77');
assert.strictEqual(actual[15], 'keySampleText-cebe54c7626cb1cefaca5f7f5ea6c96b4a7a2882');
});
});

0 comments on commit 1142e76

Please sign in to comment.