Skip to content

Commit

Permalink
fix: Code optimization on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
novakzaballa committed Oct 20, 2023
1 parent fd396a4 commit b1fc193
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/sdk/flagsmith.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,14 @@ test('test_flagsmith_uses_offline_handler_if_set_and_no_api_response', async ()
fetch.mockReturnValue(Promise.resolve(errorResponse));

// When
await flagsmith.getEnvironmentFlags();
await flagsmith.getIdentityFlags('identity', {});
const environmentFlags:Flags = await flagsmith.getEnvironmentFlags();
const identityFlags:Flags = await flagsmith.getIdentityFlags('identity', {});

// Then
expect(mock_offline_handler.getEnvironment).toHaveBeenCalledTimes(1);
expect(flagsmith.getEnvironmentFlags).toHaveBeenCalled();
expect(flagsmith.getIdentityFlags).toHaveBeenCalled();

const environmentFlags:Flags = await flagsmith.getEnvironmentFlags();
const identityFlags:Flags = await flagsmith.getIdentityFlags('identity', {});


expect(environmentFlags.isFeatureEnabled('some_feature')).toBe(true);
expect(environmentFlags.getFeatureValue('some_feature')).toBe('offline-value');

Expand Down

0 comments on commit b1fc193

Please sign in to comment.