Skip to content

Commit

Permalink
Remove test for isAppStateReady
Browse files Browse the repository at this point in the history
  • Loading branch information
timvanoostrom committed Jan 9, 2025
1 parent 1c3fd2d commit 0cd029c
Showing 1 changed file with 1 addition and 52 deletions.
53 changes: 1 addition & 52 deletions src/client/hooks/useAppState.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,12 @@ import {

import * as dataApiHook from './api/useDataApi';
import { newEventSourceMock } from './EventSourceMock';
import {
addParamsToStreamEndpoint,
isAppStateReady,
useAppStateRemote,
} from './useAppState';
import { addParamsToStreamEndpoint, useAppStateRemote } from './useAppState';
import * as sseHook from './useSSE';
import { SSE_ERROR_MESSAGE } from './useSSE';
import { renderRecoilHook } from '../../testing/render-recoil.hook';
import { FeatureToggle } from '../../universal/config/feature-toggles';
import {
apiPristineResult,
apiSuccessResult,
} from '../../universal/helpers/api';
import * as appStateModule from '../AppState';
import * as Monitoring from '../helpers/monitoring';

vi.mock('./api/useTipsApi');
vi.mock('./useProfileType');
Expand Down Expand Up @@ -152,48 +143,6 @@ describe('useAppState', () => {
});
});

describe('isAppStateReady', () => {
const pristineState = {
TEST: apiPristineResult(null, { profileTypes: ['private'] }),
};

it('Should initially be false', async () => {
const appState = { TEST: pristineState.TEST };

const isReady = isAppStateReady(appState, pristineState, 'private');
expect(isReady).toBe(false);
});

it('Should be true if we have proper data', async () => {
const isReady = isAppStateReady(
{ TEST: apiSuccessResult('test') },
pristineState,
'private'
);
expect(isReady).toBe(true);
});

it('Should be false if we have proper data but a different profile type', async () => {
const isReady = isAppStateReady(
{ TEST: apiSuccessResult('test') },
pristineState,
'commercial'
);
expect(isReady).toBe(false);
});

it('Should be false if we have statekey mismatch', async () => {
const spy = vi.spyOn(Monitoring, 'captureMessage');
const isReady = isAppStateReady(
{ BLAP: apiSuccessResult('blap') },
pristineState,
'private'
);
expect(isReady).toBe(true);
expect(spy).toHaveBeenCalledWith('unknown stateConfig key: BLAP');
});
});

test('addParamsToStreamEndpoint', () => {
const origValue = FeatureToggle.passQueryParamsToStreamUrl;
FeatureToggle.passQueryParamsToStreamUrl = false;
Expand Down

0 comments on commit 0cd029c

Please sign in to comment.