diff --git a/src/test/__tests__/common/hooks/useProcessedRecordAndSchema.test.ts b/src/test/__tests__/common/hooks/useProcessedRecordAndSchema.test.ts index 89ba955..509f074 100644 --- a/src/test/__tests__/common/hooks/useProcessedRecordAndSchema.test.ts +++ b/src/test/__tests__/common/hooks/useProcessedRecordAndSchema.test.ts @@ -1,12 +1,11 @@ import '@src/test/__mocks__/common/hooks/useServicesContext.mock'; import { useProcessedRecordAndSchema } from '@common/hooks/useProcessedRecordAndSchema.hook'; import { act, renderHook } from '@testing-library/react'; -import { useSetRecoilState } from 'recoil'; - -jest.mock('recoil'); +import { setInitialGlobalState } from '@src/test/__mocks__/store'; +import { useInputsStore, useStatusStore } from '@src/store'; describe('useProcessedRecordAndSchema', () => { - const mockSetState = jest.fn(); + const mockSetRecord = jest.fn(); const props = { baseSchema: {} as Schema, userValues: {}, @@ -14,7 +13,16 @@ describe('useProcessedRecordAndSchema', () => { }; beforeEach(() => { - (useSetRecoilState as jest.Mock).mockReturnValueOnce(mockSetState).mockReturnValueOnce(jest.fn()); + setInitialGlobalState([ + { + store: useStatusStore, + state: { addStatusMessage: jest.fn() }, + }, + { + store: useInputsStore, + state: { setRecord: mockSetRecord }, + }, + ]); }); test("doesn't update state when asked not to", () => { @@ -24,7 +32,7 @@ describe('useProcessedRecordAndSchema', () => { result.current.getProcessedRecordAndSchema({ ...props, noStateUpdate: true }); }); - expect(mockSetState).not.toHaveBeenCalled(); + expect(mockSetRecord).not.toHaveBeenCalled(); }); test('updates state when not asked to not update state', () => { @@ -34,6 +42,6 @@ describe('useProcessedRecordAndSchema', () => { result.current.getProcessedRecordAndSchema(props); }); - expect(mockSetState).toHaveBeenCalled(); + expect(mockSetRecord).toHaveBeenCalled(); }); }); diff --git a/src/test/__tests__/components/InstancesList.test.tsx b/src/test/__tests__/components/InstancesList.test.tsx index b02ff2a..129b093 100644 --- a/src/test/__tests__/components/InstancesList.test.tsx +++ b/src/test/__tests__/components/InstancesList.test.tsx @@ -1,5 +1,3 @@ -import '@src/test/__mocks__/common/hooks/useRecordControls.mock'; -import '@src/test/__mocks__/common/hooks/useNavigateToEditPage.mock'; import { navigateToEditPage } from '@src/test/__mocks__/common/hooks/useNavigateToEditPage.mock'; import { getRecordAndInitializeParsing } from '@src/test/__mocks__/common/hooks/useRecordControls.mock'; import * as RecordFormatter from '@common/helpers/recordFormatting.helper'; @@ -7,7 +5,6 @@ import { InstancesList } from '@components/InstancesList'; import { fireEvent, render } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; -jest.mock('recoil'); jest.mock('@common/constants/build.constants', () => ({ IS_EMBEDDED_MODE: true })); describe('InstancesList', () => { diff --git a/src/test/__tests__/components/TitledPreview.test.tsx b/src/test/__tests__/components/TitledPreview.test.tsx index 6b622ea..405a359 100644 --- a/src/test/__tests__/components/TitledPreview.test.tsx +++ b/src/test/__tests__/components/TitledPreview.test.tsx @@ -1,10 +1,8 @@ -import '@src/test/__mocks__/common/hooks/useNavigateToEditPage.mock'; import { navigateToEditPage } from '@src/test/__mocks__/common/hooks/useNavigateToEditPage.mock'; import { fireEvent, render } from '@testing-library/react'; import { BrowserRouter } from 'react-router-dom'; import { ITitledPreview, TitledPreview } from '@components/Preview/TitledPreview'; -jest.mock('recoil'); jest.mock('@common/constants/build.constants', () => ({ IS_EMBEDDED_MODE: true })); describe('TitledPreview', () => {