Skip to content

Commit

Permalink
Add tests for comparison attribute conversion to canonical string rep…
Browse files Browse the repository at this point in the history
…resentation
  • Loading branch information
adams85 committed Jan 30, 2024
1 parent 3dda451 commit 2dcc8e1
Show file tree
Hide file tree
Showing 2 changed files with 826 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/ConfigV2EvaluationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,43 @@ describe("Setting evaluation (config v2)", () => {
});
}

for (const [key, customAttributeValue, expectedReturnValue] of
<[string, number | Date | ReadonlyArray<string>, string][]>[
["numberToStringConversion", 0.12345, "1"],
["numberToStringConversionInt", 125, "4"],
["numberToStringConversionPositiveExp", -1.23456789e+96, "2"],
["numberToStringConversionNegativeExp", -12345.6789e-100, "4"],
["numberToStringConversionNaN", NaN, "3"],
["numberToStringConversionPositiveInf", Infinity, "4"],
["numberToStringConversionNegativeInf", -Infinity, "3"],
["dateToStringConversion", new Date("2023-03-31T23:59:59.9990000Z"), "3"],
["dateToStringConversion", 1680307199.999, "3"],
["dateToStringConversionNaN", NaN, "3"],
["dateToStringConversionPositiveInf", Infinity, "1"],
["dateToStringConversionNegativeInf", -Infinity, "5"],
["stringArrayToStringConversion", ["read", "Write", " eXecute "], "4"],
["stringArrayToStringConversionEmpty", [], "5"],
["stringArrayToStringConversionSpecialChars", ["+<>%\"'\\/\t\r\n"], "3"],
["stringArrayToStringConversionUnicode", ["äöüÄÖÜçéèñışğ⢙✓😀"], "2"],
]) {
it(`Comparison attribute conversion to canonical string representation - key: ${key} | customAttributeValue: ${customAttributeValue}`, async () => {
const configLocation = new LocalFileConfigLocation("test", "data", "comparison_attribute_conversion.json");
const config = await configLocation.fetchConfigAsync();

const fakeLogger = new FakeLogger();
const logger = new LoggerWrapper(fakeLogger);
const evaluator = new RolloutEvaluator(logger);

const user = new User("12345", void 0, void 0, {
["Custom1"]: customAttributeValue,
});

const evaluationDetails = evaluate(evaluator, config.settings, key, "default", user!, null, logger);

assert.strictEqual(evaluationDetails.value, expectedReturnValue);
});
}

for (const [key, expectedReturnValue] of
<[string, string][]>[
["isoneof", "no trim"],
Expand Down
Loading

0 comments on commit 2dcc8e1

Please sign in to comment.