diff --git a/libs/shared/flagd-core/src/lib/flagd-core.spec.ts b/libs/shared/flagd-core/src/lib/flagd-core.spec.ts index 3078b72a1..83e682dd9 100644 --- a/libs/shared/flagd-core/src/lib/flagd-core.spec.ts +++ b/libs/shared/flagd-core/src/lib/flagd-core.spec.ts @@ -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: 'test@example.com' }, + console, + ); + expect(evaluation.value).toBe(true); + expect(evaluation.variant).toBe('true'); + expect(evaluation.reason).toBe(StandardResolutionReasons.TARGETING_MATCH); + }); }); describe('flagd-core validations', () => {