Skip to content

Commit 1e2b42b

Browse files
committed
Update test to use cache
1 parent 7443c2d commit 1e2b42b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/init.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,30 @@ describe('Flagsmith.init', () => {
8686
expect(flagsmith.getTrait("a")).toEqual(undefined)
8787
});
8888
test('identifying with new identity after logout should not carry over previous traits for different identity', async () => {
89+
// Given
8990
const onChange = jest.fn()
9091
const now = Date.now();
9192
const identityA = `test_identity_a_${now}`
9293
const identityB = `test_identity_b_${now}`
93-
const {flagsmith,initConfig} = getFlagsmith({onChange, identity:identityA, traits: {a:`example`}})
94+
const { flagsmith, initConfig } = getFlagsmith({
95+
onChange,
96+
identity: identityA,
97+
traits: { a: `example` },
98+
cacheOptions: { skipAPI: true },
99+
});
94100
await flagsmith.init(initConfig);
95101
expect(flagsmith.getTrait("a")).toEqual(`example`)
96102

103+
// Also force an identify call to ensure nothing else is being set
104+
// as part of the identify call that perhaps doesn't get cleared
105+
// by logout.
106+
await flagsmith.identify(identityA)
107+
108+
// When
97109
await flagsmith.logout()
98110
await flagsmith.identify(identityB)
111+
112+
// Then
99113
expect(flagsmith.getTrait("a")).toEqual(undefined)
100114
});
101115
});

0 commit comments

Comments
 (0)