From b83d019afa020a2c9d323b8039387a3237583325 Mon Sep 17 00:00:00 2001 From: kumikokashii Date: Thu, 14 May 2020 04:26:16 -0700 Subject: [PATCH 1/2] fix: clean up mockStore for tests using createMockStore --- src/__tests__/incidents/list/ViewIncidents.test.tsx | 5 +++-- .../incidents/report/ReportIncident.test.tsx | 5 +++-- src/__tests__/incidents/view/ViewIncident.test.tsx | 5 +++-- src/__tests__/labs/ViewLab.test.tsx | 5 +++-- .../patients/allergies/NewAllergyModal.test.tsx | 11 ++++++----- .../patients/diagnoses/AddDiagnosisModal.test.tsx | 11 ++++++----- src/__tests__/patients/notes/NewNoteModal.test.tsx | 13 +++++++------ 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/__tests__/incidents/list/ViewIncidents.test.tsx b/src/__tests__/incidents/list/ViewIncidents.test.tsx index e29b5e88ef..ca8cd7b78f 100644 --- a/src/__tests__/incidents/list/ViewIncidents.test.tsx +++ b/src/__tests__/incidents/list/ViewIncidents.test.tsx @@ -14,8 +14,9 @@ import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' import ViewIncidents from '../../../incidents/list/ViewIncidents' import Incident from '../../../model/Incident' import IncidentRepository from '../../../clients/db/IncidentRepository' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('View Incidents', () => { let history: any @@ -50,7 +51,7 @@ describe('View Incidents', () => { incidents: { incidents: expectedIncidents, }, - }) + } as any) let wrapper: any await act(async () => { diff --git a/src/__tests__/incidents/report/ReportIncident.test.tsx b/src/__tests__/incidents/report/ReportIncident.test.tsx index a1824b77e9..6a9cfbf97d 100644 --- a/src/__tests__/incidents/report/ReportIncident.test.tsx +++ b/src/__tests__/incidents/report/ReportIncident.test.tsx @@ -14,8 +14,9 @@ import * as ButtonBarProvider from '../../../page-header/ButtonBarProvider' import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' import ReportIncident from '../../../incidents/report/ReportIncident' import IncidentRepository from '../../../clients/db/IncidentRepository' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Report Incident', () => { let history: any @@ -41,7 +42,7 @@ describe('Report Incident', () => { incident: { error, }, - }) + } as any) let wrapper: any await act(async () => { diff --git a/src/__tests__/incidents/view/ViewIncident.test.tsx b/src/__tests__/incidents/view/ViewIncident.test.tsx index 0ddb43fc5a..097b0fdf85 100644 --- a/src/__tests__/incidents/view/ViewIncident.test.tsx +++ b/src/__tests__/incidents/view/ViewIncident.test.tsx @@ -14,8 +14,9 @@ import * as breadcrumbUtil from '../../../breadcrumbs/useAddBreadcrumbs' import ViewIncident from '../../../incidents/view/ViewIncident' import Incident from '../../../model/Incident' import IncidentRepository from '../../../clients/db/IncidentRepository' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('View Incident', () => { const expectedDate = new Date(2020, 5, 1, 19, 48) @@ -50,7 +51,7 @@ describe('View Incident', () => { incident: { incident: expectedIncident, }, - }) + } as any) let wrapper: any await act(async () => { diff --git a/src/__tests__/labs/ViewLab.test.tsx b/src/__tests__/labs/ViewLab.test.tsx index 77472a6282..66a84f9105 100644 --- a/src/__tests__/labs/ViewLab.test.tsx +++ b/src/__tests__/labs/ViewLab.test.tsx @@ -18,8 +18,9 @@ import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelForm import format from 'date-fns/format' import * as titleUtil from '../../page-header/useTitle' import ViewLab from '../../labs/ViewLab' +import { RootState } from '../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('View Labs', () => { let history: any @@ -61,7 +62,7 @@ describe('View Labs', () => { error, status: Object.keys(error).length > 0 ? 'error' : 'completed', }, - }) + } as any) let wrapper: any await act(async () => { diff --git a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx index c9420eb4a0..c00827adc6 100644 --- a/src/__tests__/patients/allergies/NewAllergyModal.test.tsx +++ b/src/__tests__/patients/allergies/NewAllergyModal.test.tsx @@ -11,8 +11,9 @@ import TextInputWithLabelFormGroup from '../../../components/input/TextInputWith import * as patientSlice from '../../../patients/patient-slice' import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('New Allergy Modal', () => { const mockPatient = { @@ -32,7 +33,7 @@ describe('New Allergy Modal', () => { id: '123', }, }, - }) + } as any) const wrapper = mount( @@ -61,7 +62,7 @@ describe('New Allergy Modal', () => { }, allergyError: expectedError, }, - }) + } as any) const wrapper = mount( @@ -87,7 +88,7 @@ describe('New Allergy Modal', () => { id: '123', }, }, - }) + } as any) const wrapper = mount( @@ -114,7 +115,7 @@ describe('New Allergy Modal', () => { patient: { patient, }, - }) + } as any) const wrapper = mount( diff --git a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx index 9f6ba327cc..67f3fc6878 100644 --- a/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx +++ b/src/__tests__/patients/diagnoses/AddDiagnosisModal.test.tsx @@ -13,8 +13,9 @@ import Diagnosis from '../../../model/Diagnosis' import * as patientSlice from '../../../patients/patient-slice' import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Add Diagnosis Modal', () => { beforeEach(() => { @@ -29,7 +30,7 @@ describe('Add Diagnosis Modal', () => { id: '1234', }, }, - }) + } as any) const wrapper = mount( @@ -56,7 +57,7 @@ describe('Add Diagnosis Modal', () => { patient: { diagnosisError: expectedDiagnosisError, }, - }) + } as any) const wrapper = mount( @@ -87,7 +88,7 @@ describe('Add Diagnosis Modal', () => { id: '1234', }, }, - }) + } as any) const wrapper = mount( @@ -127,7 +128,7 @@ describe('Add Diagnosis Modal', () => { patient: { patient, }, - }) + } as any) const wrapper = mount( diff --git a/src/__tests__/patients/notes/NewNoteModal.test.tsx b/src/__tests__/patients/notes/NewNoteModal.test.tsx index 8ac6dafcc3..b0cb9e8c7a 100644 --- a/src/__tests__/patients/notes/NewNoteModal.test.tsx +++ b/src/__tests__/patients/notes/NewNoteModal.test.tsx @@ -11,8 +11,9 @@ import { Provider } from 'react-redux' import * as patientSlice from '../../../patients/patient-slice' import PatientRepository from '../../../clients/db/PatientRepository' import Patient from '../../../model/Patient' +import { RootState } from '../../../store' -const mockStore = createMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('New Note Modal', () => { beforeEach(() => { @@ -29,7 +30,7 @@ describe('New Note Modal', () => { patient: { patient: expectedPatient, }, - }) + } as any) const wrapper = mount( @@ -54,7 +55,7 @@ describe('New Note Modal', () => { patient: { patient: expectedPatient, }, - }) + } as any) const wrapper = mount( @@ -81,7 +82,7 @@ describe('New Note Modal', () => { patient: expectedPatient, noteError: expectedError, }, - }) + } as any) const wrapper = mount( @@ -107,7 +108,7 @@ describe('New Note Modal', () => { patient: { patient: expectedPatient, }, - }) + } as any) const wrapper = mount( @@ -136,7 +137,7 @@ describe('New Note Modal', () => { patient: { patient: expectedPatient, }, - }) + } as any) jest.spyOn(PatientRepository, 'find').mockResolvedValue(expectedPatient as Patient) jest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(expectedPatient as Patient) From c37e9c8f055c3a31c2d0f7d7897bc0c4239c271a Mon Sep 17 00:00:00 2001 From: kumikokashii Date: Thu, 14 May 2020 05:19:20 -0700 Subject: [PATCH 2/2] fix: change configureMocks to createMockStore in tests --- src/__tests__/HospitalRun.test.tsx | 19 ++++++++++--------- .../breadcrumbs/Breadcrumbs.test.tsx | 8 +++++--- .../breadcrumbs/useAddBreadcrumbs.test.tsx | 12 +++++++----- src/__tests__/components/Sidebar.test.tsx | 7 ++++--- src/__tests__/incidents/Incidents.test.tsx | 13 +++++++------ src/__tests__/labs/Labs.test.tsx | 13 +++++++------ src/__tests__/labs/ViewLabs.test.tsx | 17 +++++++++-------- .../labs/requests/NewLabRequest.test.tsx | 15 ++++++++------- src/__tests__/page-header/useTitle.test.tsx | 7 ++++--- src/__tests__/patients/Patients.test.tsx | 19 ++++++++++--------- .../patients/allergies/Allergies.test.tsx | 7 ++++--- .../appointments/AppointmentsList.test.tsx | 7 ++++--- .../patients/diagnoses/Diagnoses.test.tsx | 7 ++++--- .../patients/edit/EditPatient.test.tsx | 7 ++++--- src/__tests__/patients/labs/LabsTab.test.tsx | 7 ++++--- .../patients/new/NewPatient.test.tsx | 7 ++++--- .../patients/notes/NotesTab.test.tsx | 7 ++++--- .../AddRelatedPersonModal.test.tsx | 11 ++++++----- .../related-persons/RelatedPersons.test.tsx | 13 +++++++------ .../patients/view/ViewPatient.test.tsx | 7 ++++--- .../appointments/Appointments.test.tsx | 19 ++++++++++--------- .../appointments/ViewAppointments.test.tsx | 7 ++++--- .../edit/EditAppointment.test.tsx | 7 ++++--- .../appointments/new/NewAppointment.test.tsx | 7 ++++--- .../view/ViewAppointment.test.tsx | 7 ++++--- 25 files changed, 142 insertions(+), 115 deletions(-) diff --git a/src/__tests__/HospitalRun.test.tsx b/src/__tests__/HospitalRun.test.tsx index 244678e912..5e919d7412 100644 --- a/src/__tests__/HospitalRun.test.tsx +++ b/src/__tests__/HospitalRun.test.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import { MemoryRouter } from 'react-router-dom' import { Provider } from 'react-redux' import thunk from 'redux-thunk' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { Toaster } from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import Dashboard from 'dashboard/Dashboard' @@ -15,8 +15,9 @@ import Appointments from 'scheduling/appointments/Appointments' import HospitalRun from '../HospitalRun' import Permissions from '../model/Permissions' import Incidents from '../incidents/Incidents' +import { RootState } from '../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('HospitalRun', () => { describe('routing', () => { @@ -29,7 +30,7 @@ describe('HospitalRun', () => { breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, incidents: { incidents: [] }, - }) + } as any) const wrapper = mount( @@ -61,7 +62,7 @@ describe('HospitalRun', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -82,7 +83,7 @@ describe('HospitalRun', () => { labs: { labs: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) let wrapper: any await act(async () => { @@ -106,7 +107,7 @@ describe('HospitalRun', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -129,7 +130,7 @@ describe('HospitalRun', () => { breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, incidents: { incidents: [] }, - }) + } as any) let wrapper: any await act(async () => { @@ -153,7 +154,7 @@ describe('HospitalRun', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -178,7 +179,7 @@ describe('HospitalRun', () => { user: { permissions: [Permissions.WritePatients] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > diff --git a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx b/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx index f14bc46b9f..b6198d1269 100644 --- a/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx +++ b/src/__tests__/breadcrumbs/Breadcrumbs.test.tsx @@ -4,7 +4,7 @@ import { Provider } from 'react-redux' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' import { Router } from 'react-router-dom' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { Breadcrumb as HRBreadcrumb, BreadcrumbItem as HRBreadcrumbItem, @@ -12,15 +12,17 @@ import { import Breadcrumbs from 'breadcrumbs/Breadcrumbs' import Breadcrumb from 'model/Breadcrumb' +import thunk from 'redux-thunk' +import { RootState } from '../../store' -const mockStore = configureMockStore() +const mockStore = createMockStore([thunk]) describe('Breadcrumbs', () => { const setup = (breadcrumbs: Breadcrumb[]) => { const history = createMemoryHistory() const store = mockStore({ breadcrumbs: { breadcrumbs }, - }) + } as any) const wrapper = mount( diff --git a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx b/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx index 452f76ebdc..5b0f8aff1c 100644 --- a/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx +++ b/src/__tests__/breadcrumbs/useAddBreadcrumbs.test.tsx @@ -1,17 +1,19 @@ import React from 'react' import { renderHook } from '@testing-library/react-hooks' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { Provider } from 'react-redux' +import thunk from 'redux-thunk' import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import * as breadcrumbsSlice from '../../breadcrumbs/breadcrumbs-slice' +import { RootState } from '../../store' -const store = configureMockStore() +const mockStore = createMockStore([thunk]) describe('useAddBreadcrumbs', () => { beforeEach(() => jest.clearAllMocks()) it('should call addBreadcrumbs with the correct data', () => { - const wrapper = ({ children }: any) => {children} + const wrapper = ({ children }: any) => {children} jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs') const breadcrumbs = [ @@ -27,7 +29,7 @@ describe('useAddBreadcrumbs', () => { }) it('should call addBreadcrumbs with an additional dashboard breadcrumb', () => { - const wrapper = ({ children }: any) => {children} + const wrapper = ({ children }: any) => {children} jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs') const breadcrumbs = [ @@ -46,7 +48,7 @@ describe('useAddBreadcrumbs', () => { }) it('should call removeBreadcrumbs with the correct data after unmount', () => { - const wrapper = ({ children }: any) => {children} + const wrapper = ({ children }: any) => {children} jest.spyOn(breadcrumbsSlice, 'addBreadcrumbs') jest.spyOn(breadcrumbsSlice, 'removeBreadcrumbs') diff --git a/src/__tests__/components/Sidebar.test.tsx b/src/__tests__/components/Sidebar.test.tsx index 52f3d4e794..89186c1e73 100644 --- a/src/__tests__/components/Sidebar.test.tsx +++ b/src/__tests__/components/Sidebar.test.tsx @@ -6,17 +6,18 @@ import Sidebar from 'components/Sidebar' import { Router } from 'react-router-dom' import { ListItem } from '@hospitalrun/components' import { act } from '@testing-library/react' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { Provider } from 'react-redux' +import { RootState } from '../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Sidebar', () => { let history = createMemoryHistory() const store = mockStore({ components: { sidebarCollapsed: false }, - }) + } as any) const setup = (location: string) => { history = createMemoryHistory() history.push(location) diff --git a/src/__tests__/incidents/Incidents.test.tsx b/src/__tests__/incidents/Incidents.test.tsx index 51913eafa4..34079ce554 100644 --- a/src/__tests__/incidents/Incidents.test.tsx +++ b/src/__tests__/incidents/Incidents.test.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import { MemoryRouter } from 'react-router' import { Provider } from 'react-redux' import thunk from 'redux-thunk' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { act } from '@testing-library/react' import Permissions from 'model/Permissions' import ViewIncident from '../../incidents/view/ViewIncident' @@ -12,8 +12,9 @@ import Incidents from '../../incidents/Incidents' import ReportIncident from '../../incidents/report/ReportIncident' import Incident from '../../model/Incident' import IncidentRepository from '../../clients/db/IncidentRepository' +import { RootState } from '../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Incidents', () => { describe('routing', () => { @@ -32,7 +33,7 @@ describe('Incidents', () => { incident: { incident: expectedIncident, }, - }) + } as any) const wrapper = mount( @@ -51,7 +52,7 @@ describe('Incidents', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -80,7 +81,7 @@ describe('Incidents', () => { reportedOn: new Date().toISOString(), }, }, - }) + } as any) let wrapper: any @@ -103,7 +104,7 @@ describe('Incidents', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = await mount( diff --git a/src/__tests__/labs/Labs.test.tsx b/src/__tests__/labs/Labs.test.tsx index 2836514d7e..1f1ac1c87d 100644 --- a/src/__tests__/labs/Labs.test.tsx +++ b/src/__tests__/labs/Labs.test.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import { MemoryRouter } from 'react-router-dom' import { Provider } from 'react-redux' import thunk from 'redux-thunk' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { act } from '@testing-library/react' import Labs from 'labs/Labs' import NewLabRequest from 'labs/requests/NewLabRequest' @@ -14,8 +14,9 @@ import LabRepository from 'clients/db/LabRepository' import Lab from 'model/Lab' import Patient from 'model/Patient' import PatientRepository from 'clients/db/PatientRepository' +import { RootState } from '../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Labs', () => { jest.spyOn(LabRepository, 'findAll').mockResolvedValue([]) @@ -39,7 +40,7 @@ describe('Labs', () => { patient: { id: 'patientId', fullName: 'some name' }, error: {}, }, - }) + } as any) const wrapper = mount( @@ -58,7 +59,7 @@ describe('Labs', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -88,7 +89,7 @@ describe('Labs', () => { patient: { id: 'patientId', fullName: 'some name' }, error: {}, }, - }) + } as any) let wrapper: any @@ -111,7 +112,7 @@ describe('Labs', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = await mount( diff --git a/src/__tests__/labs/ViewLabs.test.tsx b/src/__tests__/labs/ViewLabs.test.tsx index 2a7da00e67..8bdc8716b6 100644 --- a/src/__tests__/labs/ViewLabs.test.tsx +++ b/src/__tests__/labs/ViewLabs.test.tsx @@ -5,7 +5,7 @@ import { Router } from 'react-router-dom' import ViewLabs from 'labs/ViewLabs' import { mount, ReactWrapper } from 'enzyme' import { TextInput, Select } from '@hospitalrun/components' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { createMemoryHistory } from 'history' import Permissions from 'model/Permissions' @@ -16,8 +16,9 @@ import Lab from 'model/Lab' import format from 'date-fns/format' import * as ButtonBarProvider from 'page-header/ButtonBarProvider' import * as titleUtil from '../../page-header/useTitle' +import { RootState } from '../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('View Labs', () => { describe('title', () => { @@ -27,7 +28,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] }, labs: { labs: [] }, - }) + } as any) titleSpy = jest.spyOn(titleUtil, 'default') jest.spyOn(LabRepository, 'findAll').mockResolvedValue([]) await act(async () => { @@ -52,7 +53,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] }, labs: { labs: [] }, - }) + } as any) const setButtonToolBarSpy = jest.fn() jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter').mockReturnValue(setButtonToolBarSpy) jest.spyOn(LabRepository, 'findAll').mockResolvedValue([]) @@ -75,7 +76,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs] }, labs: { labs: [] }, - }) + } as any) const setButtonToolBarSpy = jest.fn() jest.spyOn(ButtonBarProvider, 'useButtonToolbarSetter').mockReturnValue(setButtonToolBarSpy) jest.spyOn(LabRepository, 'findAll').mockResolvedValue([]) @@ -111,7 +112,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] }, labs: { labs: [expectedLab] }, - }) + } as any) history = createMemoryHistory() jest.spyOn(LabRepository, 'findAll').mockResolvedValue([expectedLab]) @@ -190,7 +191,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] }, labs: { labs: [expectedLab] }, - }) + } as any) history = createMemoryHistory() await act(async () => { @@ -243,7 +244,7 @@ describe('View Labs', () => { title: '', user: { permissions: [Permissions.ViewLabs, Permissions.RequestLab] }, labs: { labs: [expectedLab] }, - }) + } as any) history = createMemoryHistory() jest.spyOn(LabRepository, 'findAll').mockResolvedValue([expectedLab]) diff --git a/src/__tests__/labs/requests/NewLabRequest.test.tsx b/src/__tests__/labs/requests/NewLabRequest.test.tsx index 7e280b0e58..e832109747 100644 --- a/src/__tests__/labs/requests/NewLabRequest.test.tsx +++ b/src/__tests__/labs/requests/NewLabRequest.test.tsx @@ -7,7 +7,7 @@ import { mount, ReactWrapper } from 'enzyme' import { Button, Typeahead, Label, Alert } from '@hospitalrun/components' import { Router } from 'react-router-dom' import { Provider } from 'react-redux' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { createMemoryHistory } from 'history' import { act } from 'react-dom/test-utils' @@ -16,8 +16,9 @@ import PatientRepository from 'clients/db/PatientRepository' import Lab from 'model/Lab' import Patient from 'model/Patient' import * as titleUtil from '../../../page-header/useTitle' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('New Lab Request', () => { describe('title and breadcrumbs', () => { @@ -25,7 +26,7 @@ describe('New Lab Request', () => { const history = createMemoryHistory() beforeEach(() => { - const store = mockStore({ title: '', lab: { status: 'loading', error: {} } }) + const store = mockStore({ title: '', lab: { status: 'loading', error: {} } } as any) titleSpy = jest.spyOn(titleUtil, 'default') history.push('/labs/new') @@ -48,7 +49,7 @@ describe('New Lab Request', () => { const history = createMemoryHistory() beforeEach(() => { - const store = mockStore({ title: '', lab: { status: 'loading', error: {} } }) + const store = mockStore({ title: '', lab: { status: 'loading', error: {} } } as any) history.push('/labs/new') wrapper = mount( @@ -117,7 +118,7 @@ describe('New Lab Request', () => { beforeEach(() => { history.push('/labs/new') - const store = mockStore({ title: '', lab: { status: 'error', error } }) + const store = mockStore({ title: '', lab: { status: 'error', error } } as any) wrapper = mount( @@ -149,7 +150,7 @@ describe('New Lab Request', () => { beforeEach(() => { history.push('/labs/new') - const store = mockStore({ title: '', lab: { status: 'loading', error: {} } }) + const store = mockStore({ title: '', lab: { status: 'loading', error: {} } } as any) wrapper = mount( @@ -195,7 +196,7 @@ describe('New Lab Request', () => { .mockResolvedValue([{ id: expectedLab.patientId, fullName: 'some full name' }] as Patient[]) history.push('/labs/new') - const store = mockStore({ title: '', lab: { status: 'loading', error: {} } }) + const store = mockStore({ title: '', lab: { status: 'loading', error: {} } } as any) wrapper = mount( diff --git a/src/__tests__/page-header/useTitle.test.tsx b/src/__tests__/page-header/useTitle.test.tsx index a913147e81..ac1defd7d5 100644 --- a/src/__tests__/page-header/useTitle.test.tsx +++ b/src/__tests__/page-header/useTitle.test.tsx @@ -1,16 +1,17 @@ import React from 'react' import { renderHook } from '@testing-library/react-hooks' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { Provider } from 'react-redux' import useTitle from '../../page-header/useTitle' import * as titleSlice from '../../page-header/title-slice' +import { RootState } from '../../store' -const store = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('useTitle', () => { it('should call the updateTitle with the correct data', () => { - const wrapper = ({ children }: any) => {children} + const wrapper = ({ children }: any) => {children} jest.spyOn(titleSlice, 'updateTitle') const expectedTitle = 'title' diff --git a/src/__tests__/patients/Patients.test.tsx b/src/__tests__/patients/Patients.test.tsx index a37c8979e1..ce4f42bc31 100644 --- a/src/__tests__/patients/Patients.test.tsx +++ b/src/__tests__/patients/Patients.test.tsx @@ -2,7 +2,7 @@ import '../../__mocks__/matchMediaMock' import React from 'react' import { Provider } from 'react-redux' import { MemoryRouter } from 'react-router' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { mount } from 'enzyme' import thunk from 'redux-thunk' import { act } from 'react-dom/test-utils' @@ -15,8 +15,9 @@ import PatientRepository from '../../clients/db/PatientRepository' import Patient from '../../model/Patient' import EditPatient from '../../patients/edit/EditPatient' import ViewPatient from '../../patients/view/ViewPatient' +import { RootState } from '../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('/patients/new', () => { it('should render the new patient screen when /patients/new is accessed', async () => { @@ -26,7 +27,7 @@ describe('/patients/new', () => { patient: {}, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) let wrapper: any @@ -59,7 +60,7 @@ describe('/patients/new', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -90,7 +91,7 @@ describe('/patients/edit/:id', () => { patient: { patient }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -120,7 +121,7 @@ describe('/patients/edit/:id', () => { user: { permissions: [Permissions.WritePatients] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -139,7 +140,7 @@ describe('/patients/edit/:id', () => { user: { permissions: [Permissions.ReadPatients] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -170,7 +171,7 @@ describe('/patients/:id', () => { patient: { patient }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -199,7 +200,7 @@ describe('/patients/:id', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > diff --git a/src/__tests__/patients/allergies/Allergies.test.tsx b/src/__tests__/patients/allergies/Allergies.test.tsx index 33161c8a7e..622f65c2b1 100644 --- a/src/__tests__/patients/allergies/Allergies.test.tsx +++ b/src/__tests__/patients/allergies/Allergies.test.tsx @@ -3,7 +3,7 @@ import React from 'react' import { mount } from 'enzyme' import Allergies from 'patients/allergies/Allergies' import Permissions from 'model/Permissions' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { createMemoryHistory } from 'history' import thunk from 'redux-thunk' import { Router } from 'react-router-dom' @@ -13,8 +13,9 @@ import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import PatientRepository from 'clients/db/PatientRepository' import Allergy from 'model/Allergy' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const history = createMemoryHistory() const expectedPatient = { id: '123', @@ -30,7 +31,7 @@ let store: any const setup = (patient = expectedPatient, permissions = [Permissions.AddAllergy]) => { user = { permissions } - store = mockStore({ patient, user }) + store = mockStore({ patient, user } as any) const wrapper = mount( diff --git a/src/__tests__/patients/appointments/AppointmentsList.test.tsx b/src/__tests__/patients/appointments/AppointmentsList.test.tsx index e520fa8c38..0eec654b33 100644 --- a/src/__tests__/patients/appointments/AppointmentsList.test.tsx +++ b/src/__tests__/patients/appointments/AppointmentsList.test.tsx @@ -2,7 +2,7 @@ import '../../../__mocks__/matchMediaMock' import React from 'react' import { mount, ReactWrapper } from 'enzyme' import { createMemoryHistory } from 'history' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import Patient from 'model/Patient' import { Router } from 'react-router-dom' @@ -11,6 +11,7 @@ import AppointmentsList from 'patients/appointments/AppointmentsList' import * as components from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import * as appointmentsSlice from '../../../scheduling/appointments/appointments-slice' +import { RootState } from '../../../store' const expectedPatient = { id: '123', @@ -37,13 +38,13 @@ const expectedAppointments = [ }, ] -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const history = createMemoryHistory() let store: any const setup = (patient = expectedPatient, appointments = expectedAppointments) => { - store = mockStore({ patient, appointments: { appointments } }) + store = mockStore({ patient, appointments: { appointments } } as any) const wrapper = mount( diff --git a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx index f88f7ef982..e3e9d384c4 100644 --- a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx +++ b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx @@ -2,7 +2,7 @@ import '../../../__mocks__/matchMediaMock' import React from 'react' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import Patient from 'model/Patient' import Diagnosis from 'model/Diagnosis' @@ -13,6 +13,7 @@ import Diagnoses from 'patients/diagnoses/Diagnoses' import * as components from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import PatientRepository from 'clients/db/PatientRepository' +import { RootState } from '../../../store' const expectedPatient = { id: '123', @@ -21,7 +22,7 @@ const expectedPatient = { ], } as Patient -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const history = createMemoryHistory() let user: any @@ -29,7 +30,7 @@ let store: any const setup = (patient = expectedPatient, permissions = [Permissions.AddDiagnosis]) => { user = { permissions } - store = mockStore({ patient, user }) + store = mockStore({ patient, user } as any) const wrapper = mount( diff --git a/src/__tests__/patients/edit/EditPatient.test.tsx b/src/__tests__/patients/edit/EditPatient.test.tsx index 62de9c53a9..9ecd4ba2c0 100644 --- a/src/__tests__/patients/edit/EditPatient.test.tsx +++ b/src/__tests__/patients/edit/EditPatient.test.tsx @@ -5,7 +5,7 @@ import { Router, Route } from 'react-router-dom' import { Provider } from 'react-redux' import { createMemoryHistory } from 'history' import { act } from 'react-dom/test-utils' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { Button } from '@hospitalrun/components' import { subDays } from 'date-fns' @@ -15,8 +15,9 @@ import Patient from '../../../model/Patient' import * as titleUtil from '../../../page-header/useTitle' import * as patientSlice from '../../../patients/patient-slice' import PatientRepository from '../../../clients/db/PatientRepository' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Edit Patient', () => { const patient = { @@ -45,7 +46,7 @@ describe('Edit Patient', () => { jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient) history = createMemoryHistory() - store = mockStore({ patient: { patient } }) + store = mockStore({ patient: { patient } } as any) history.push('/patients/edit/123') const wrapper = mount( diff --git a/src/__tests__/patients/labs/LabsTab.test.tsx b/src/__tests__/patients/labs/LabsTab.test.tsx index b9d9c24f64..fec0584787 100644 --- a/src/__tests__/patients/labs/LabsTab.test.tsx +++ b/src/__tests__/patients/labs/LabsTab.test.tsx @@ -1,6 +1,6 @@ import '../../../__mocks__/matchMediaMock' import React from 'react' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { mount } from 'enzyme' import { createMemoryHistory } from 'history' @@ -14,6 +14,7 @@ import Patient from '../../../model/Patient' import Lab from '../../../model/Lab' import Permissions from '../../../model/Permissions' import LabRepository from '../../../clients/db/LabRepository' +import { RootState } from '../../../store' const expectedPatient = { id: '123', @@ -29,7 +30,7 @@ const labs = [ } as Lab, ] -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const history = createMemoryHistory() let user: any @@ -37,7 +38,7 @@ let store: any const setup = (patient = expectedPatient, permissions = [Permissions.WritePatients]) => { user = { permissions } - store = mockStore({ patient, user }) + store = mockStore({ patient, user } as any) jest.spyOn(LabRepository, 'findAllByPatientId').mockResolvedValue(labs) const wrapper = mount( diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index dbea001bc0..49d2e0010a 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -6,7 +6,7 @@ import { Provider } from 'react-redux' import { mocked } from 'ts-jest/utils' import { createMemoryHistory } from 'history' import { act } from 'react-dom/test-utils' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import * as components from '@hospitalrun/components' import NewPatient from '../../../patients/new/NewPatient' @@ -15,8 +15,9 @@ import Patient from '../../../model/Patient' import * as patientSlice from '../../../patients/patient-slice' import * as titleUtil from '../../../page-header/useTitle' import PatientRepository from '../../../clients/db/PatientRepository' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('New Patient', () => { const patient = { @@ -33,7 +34,7 @@ describe('New Patient', () => { mockedPatientRepository.save.mockResolvedValue(patient) history = createMemoryHistory() - store = mockStore({ patient: { patient: {} as Patient, createError: error } }) + store = mockStore({ patient: { patient: {} as Patient, createError: error } } as any) history.push('/patients/new') const wrapper = mount( diff --git a/src/__tests__/patients/notes/NotesTab.test.tsx b/src/__tests__/patients/notes/NotesTab.test.tsx index 454f217ba3..5937d26cd4 100644 --- a/src/__tests__/patients/notes/NotesTab.test.tsx +++ b/src/__tests__/patients/notes/NotesTab.test.tsx @@ -3,7 +3,7 @@ import React from 'react' import PatientRepository from 'clients/db/PatientRepository' import Note from 'model/Note' import { createMemoryHistory } from 'history' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import Patient from 'model/Patient' import thunk from 'redux-thunk' import { mount } from 'enzyme' @@ -13,13 +13,14 @@ import NoteTab from 'patients/notes/NoteTab' import * as components from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import Permissions from '../../../model/Permissions' +import { RootState } from '../../../store' const expectedPatient = { id: '123', notes: [{ date: new Date().toISOString(), text: 'notes1' } as Note], } as Patient -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const history = createMemoryHistory() let user: any @@ -27,7 +28,7 @@ let store: any const setup = (patient = expectedPatient, permissions = [Permissions.WritePatients]) => { user = { permissions } - store = mockStore({ patient, user }) + store = mockStore({ patient, user } as any) const wrapper = mount( diff --git a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx index 4ef438bd50..69342ae725 100644 --- a/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx +++ b/src/__tests__/patients/related-persons/AddRelatedPersonModal.test.tsx @@ -5,14 +5,15 @@ import { Modal, Alert, Typeahead } from '@hospitalrun/components' import { act } from '@testing-library/react' import { Provider } from 'react-redux' import thunk from 'redux-thunk' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import Patient from 'model/Patient' import TextInputWithLabelFormGroup from '../../../components/input/TextInputWithLabelFormGroup' import AddRelatedPersonModal from '../../../patients/related-persons/AddRelatedPersonModal' import * as patientSlice from '../../../patients/patient-slice' import PatientRepository from '../../../clients/db/PatientRepository' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Add Related Person Modal', () => { const patient = { @@ -39,7 +40,7 @@ describe('Add Related Person Modal', () => { store = mockStore({ patient: { patient }, - }) + } as any) beforeEach(() => { jest.spyOn(PatientRepository, 'find').mockResolvedValue(patient) jest.spyOn(PatientRepository, 'saveOrUpdate').mockResolvedValue(patient) @@ -100,7 +101,7 @@ describe('Add Related Person Modal', () => { patient, relatedPersonError: expectedError, }, - }) + } as any) wrapper = mount( @@ -126,7 +127,7 @@ describe('Add Related Person Modal', () => { patient: { patient, }, - }) + } as any) beforeEach(() => { wrapper = mount( diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx index b715de3c93..9b427de8ca 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx @@ -9,14 +9,15 @@ import AddRelatedPersonModal from 'patients/related-persons/AddRelatedPersonModa import { act } from '@testing-library/react' import PatientRepository from 'clients/db/PatientRepository' import Patient from 'model/Patient' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { Provider } from 'react-redux' import Permissions from 'model/Permissions' import RelatedPerson from 'model/RelatedPerson' import * as patientSlice from '../../../patients/patient-slice' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Related Persons Tab', () => { let wrapper: any @@ -45,7 +46,7 @@ describe('Related Persons Tab', () => { act(() => { wrapper = mount( - + , @@ -65,7 +66,7 @@ describe('Related Persons Tab', () => { act(() => { wrapper = mount( - + , @@ -121,7 +122,7 @@ describe('Related Persons Tab', () => { await act(async () => { wrapper = await mount( - + , @@ -201,7 +202,7 @@ describe('Related Persons Tab', () => { await act(async () => { wrapper = await mount( - + , diff --git a/src/__tests__/patients/view/ViewPatient.test.tsx b/src/__tests__/patients/view/ViewPatient.test.tsx index 3080e73384..8a0d3dd815 100644 --- a/src/__tests__/patients/view/ViewPatient.test.tsx +++ b/src/__tests__/patients/view/ViewPatient.test.tsx @@ -6,7 +6,7 @@ import { mocked } from 'ts-jest/utils' import { act } from 'react-dom/test-utils' import { Route, Router } from 'react-router-dom' import { TabsHeader, Tab } from '@hospitalrun/components' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import GeneralInformation from 'patients/GeneralInformation' import { createMemoryHistory } from 'history' @@ -23,8 +23,9 @@ import * as patientSlice from '../../../patients/patient-slice' import Permissions from '../../../model/Permissions' import LabsTab from '../../../patients/labs/LabsTab' import LabRepository from '../../../clients/db/LabRepository' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('ViewPatient', () => { const patient = { @@ -56,7 +57,7 @@ describe('ViewPatient', () => { store = mockStore({ patient: { patient }, user: { permissions }, - }) + } as any) history.push('/patients/123') const wrapper = mount( diff --git a/src/__tests__/scheduling/appointments/Appointments.test.tsx b/src/__tests__/scheduling/appointments/Appointments.test.tsx index c6acd3459a..c9c1fadf72 100644 --- a/src/__tests__/scheduling/appointments/Appointments.test.tsx +++ b/src/__tests__/scheduling/appointments/Appointments.test.tsx @@ -2,7 +2,7 @@ import '../../../__mocks__/matchMediaMock' import React from 'react' import { Provider } from 'react-redux' import { MemoryRouter } from 'react-router' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import { mount } from 'enzyme' import thunk from 'redux-thunk' import { act } from 'react-dom/test-utils' @@ -17,8 +17,9 @@ import PatientRepository from '../../../clients/db/PatientRepository' import AppointmentRepository from '../../../clients/db/AppointmentRepository' import Patient from '../../../model/Patient' import Appointment from '../../../model/Appointment' +import { RootState } from '../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('/appointments', () => { it('should render the appointments screen when /appointments is accessed', async () => { @@ -28,7 +29,7 @@ describe('/appointments', () => { appointments: { appointments: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -60,7 +61,7 @@ describe('/appointments', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -80,7 +81,7 @@ describe('/appointments/new', () => { appointment: {}, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -110,7 +111,7 @@ describe('/appointments/new', () => { user: { permissions: [] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -142,7 +143,7 @@ describe('/appointments/edit/:id', () => { appointment: { appointment, patient: {} as Patient }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - }) + } as any) const wrapper = mount( @@ -175,7 +176,7 @@ describe('/appointments/edit/:id', () => { user: { permissions: [Permissions.WriteAppointments] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > @@ -194,7 +195,7 @@ describe('/appointments/edit/:id', () => { user: { permissions: [Permissions.ReadAppointments] }, breadcrumbs: { breadcrumbs: [] }, components: { sidebarCollapsed: false }, - })} + } as any)} > diff --git a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx index 2f5db67cf3..597519aee7 100644 --- a/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx +++ b/src/__tests__/scheduling/appointments/ViewAppointments.test.tsx @@ -4,7 +4,7 @@ import { mount } from 'enzyme' import { MemoryRouter } from 'react-router-dom' import { Provider } from 'react-redux' import ViewAppointments from 'scheduling/appointments/ViewAppointments' -import configureMockStore from 'redux-mock-store' +import createMockStore from 'redux-mock-store' import thunk from 'redux-thunk' import { Calendar } from '@hospitalrun/components' import { act } from '@testing-library/react' @@ -15,6 +15,7 @@ import * as ButtonBarProvider from 'page-header/ButtonBarProvider' import AppointmentRepository from 'clients/db/AppointmentRepository' import Appointment from 'model/Appointment' import * as titleUtil from '../../../page-header/useTitle' +import { RootState } from '../../../store' describe('ViewAppointments', () => { const expectedAppointments = [ @@ -37,9 +38,9 @@ describe('ViewAppointments', () => { id: '123', fullName: 'patient full name', } as Patient) - const mockStore = configureMockStore([thunk]) + const mockStore = createMockStore([thunk]) return mount( - + diff --git a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx index 0a4cdca935..728b092ea7 100644 --- a/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/edit/EditAppointment.test.tsx @@ -6,7 +6,7 @@ import { Provider } from 'react-redux' import { mocked } from 'ts-jest/utils' import { createMemoryHistory } from 'history' import { act } from 'react-dom/test-utils' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import { roundToNearestMinutes, addMinutes } from 'date-fns' import { Button } from '@hospitalrun/components' @@ -18,8 +18,9 @@ import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' import AppointmentRepository from '../../../../clients/db/AppointmentRepository' import PatientRepository from '../../../../clients/db/PatientRepository' +import { RootState } from '../../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) describe('Edit Appointment', () => { const appointment = { @@ -66,7 +67,7 @@ describe('Edit Appointment', () => { mockedPatientRepository.find.mockResolvedValue(patient) history = createMemoryHistory() - store = mockStore({ appointment: { appointment, patient } }) + store = mockStore({ appointment: { appointment, patient } } as any) history.push('/appointments/edit/123') const wrapper = mount( diff --git a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx index 056abb1eb1..6c08dcbde4 100644 --- a/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/new/NewAppointment.test.tsx @@ -9,7 +9,7 @@ import { createMemoryHistory, MemoryHistory } from 'history' import { act } from '@testing-library/react' import AppointmentRepository from 'clients/db/AppointmentRepository' import { mocked } from 'ts-jest/utils' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import Appointment from 'model/Appointment' import Patient from 'model/Patient' @@ -19,8 +19,9 @@ import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' import LabRepository from '../../../../clients/db/LabRepository' import Lab from '../../../../model/Lab' +import { RootState } from '../../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const mockedComponents = mocked(components, true) describe('New Appointment', () => { @@ -41,7 +42,7 @@ describe('New Appointment', () => { appointment: {} as Appointment, patient: {} as Patient, }, - }) + } as any) history.push('/appointments/new') const wrapper = mount( diff --git a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx index 36472d9218..9e1cd8d7df 100644 --- a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx @@ -2,7 +2,7 @@ import '../../../../__mocks__/matchMediaMock' import React from 'react' import { mount } from 'enzyme' import { Provider } from 'react-redux' -import configureMockStore, { MockStore } from 'redux-mock-store' +import createMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import Appointment from 'model/Appointment' import ViewAppointment from 'scheduling/appointments/view/ViewAppointment' @@ -19,8 +19,9 @@ import * as ButtonBarProvider from 'page-header/ButtonBarProvider' import Permissions from 'model/Permissions' import * as titleUtil from '../../../../page-header/useTitle' import * as appointmentSlice from '../../../../scheduling/appointments/appointment-slice' +import { RootState } from '../../../../store' -const mockStore = configureMockStore([thunk]) +const mockStore = createMockStore([thunk]) const appointment = { id: '123', @@ -62,7 +63,7 @@ describe('View Appointment', () => { status, patient, }, - }) + } as any) const wrapper = mount(