Skip to content

Commit 7c5467e

Browse files
committed
add getIdentityFlags failure test
1 parent 5f277e0 commit 7c5467e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/sdk/flagsmith-identity-flags.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import Flagsmith from '../../sdk/index.js';
2-
import { fetch, environmentJSON, flagsmith, identitiesJSON, identityWithTransientTraitsJSON, transientIdentityJSON } from './utils.js';
2+
import {
3+
fetch,
4+
environmentJSON,
5+
flagsmith,
6+
identitiesJSON,
7+
identityWithTransientTraitsJSON,
8+
transientIdentityJSON,
9+
badFetch
10+
} from './utils.js';
311
import { DefaultFlag } from '../../sdk/models.js';
412

513
vi.mock('../../sdk/polling_manager');
@@ -205,3 +213,12 @@ test('test_identity_with_transient_traits', async () => {
205213
expect(identityFlags[0].value).toBe('some-identity-with-transient-trait-value');
206214
expect(identityFlags[0].featureName).toBe('some_feature');
207215
});
216+
217+
test('getIdentityFlags fails if API call failed and no default flag handler was provided', async () => {
218+
const flg = flagsmith({
219+
fetch: badFetch,
220+
})
221+
expect(flg.getIdentityFlags('user'))
222+
.rejects
223+
.toThrow('getIdentityFlags failed and no default flag handler was provided')
224+
})

0 commit comments

Comments
 (0)