Skip to content

Commit

Permalink
test: add target value casting test (#652)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Beemer <[email protected]>
  • Loading branch information
beeme1mr authored Nov 14, 2023
1 parent ca7efd3 commit a66f514
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions libs/shared/flagd-core/src/lib/flagd-core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ describe('flagd-core targeting evaluations', () => {
expect(resolved.reason).toBe(StandardResolutionReasons.TARGETING_MATCH);
expect(resolved.variant).toBe('true');
});

it('should match the variant "true" by casting the boolean response from the targeting evaluation', () => {
const caseVariantValueFlag =
'{"flags":{"new-welcome-banner":{"state":"ENABLED","variants":{"true":true,"false":false},"defaultVariant":"false","targeting":{"in":["@example.com",{"var":"email"}]}}}}';

const core = new FlagdCore();
core.setConfigurations(caseVariantValueFlag);

const evaluation = core.resolveBooleanEvaluation(
'new-welcome-banner',
false,
{ email: '[email protected]' },
console,
);
expect(evaluation.value).toBe(true);
expect(evaluation.variant).toBe('true');
expect(evaluation.reason).toBe(StandardResolutionReasons.TARGETING_MATCH);
});
});

describe('flagd-core validations', () => {
Expand Down

0 comments on commit a66f514

Please sign in to comment.