Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ describe('given an LDClient with test data', () => {
expect(stringRes).toBe('potato');
});

it('evaluates a value for all flag to its value when targeting is off', async () => {
await td.update(td.flag('flagkey').valueForAll('potato').on(false));
const detail = await client.variationDetail('flagkey', defaultUser, 'default');
expect(detail.value).toEqual('potato');
expect(detail.variationIndex).toEqual(0);
expect(detail.reason).toEqual({ kind: 'OFF' });
});

it('evaluates an existing boolean flag', async () => {
td.update(td.flag('flagkey').booleanFlag().on(true));
expect(await client.boolVariation('flagkey', defaultUser, false)).toEqual(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ describe('given a TestData instance', () => {
const built = flag.build(1);
expect(built.variations).toEqual(['potato']);
expect(built.fallthrough.variation).toEqual(0);
expect(built.offVariation).toEqual(0);
});

it('sets the off variation to the value for all when targeting is off', () => {
const built = td.flag('test-flag').valueForAll('potato').on(false).build(1);
expect(built.on).toBe(false);
expect(built.variations).toEqual(['potato']);
expect(built.offVariation).toEqual(0);
});

it('can handle boolean values for *Variation setters', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default class TestDataFlagBuilder {
* @return the flag builder
*/
valueForAll(value: any): TestDataFlagBuilder {
return this.variations(value).variationForAll(0);
return this.variations(value).variationForAll(0).offVariation(0);
}

/**
Expand Down
Loading