diff --git a/src/__tests__/patients/list/ViewPatients.test.tsx b/src/__tests__/patients/list/ViewPatients.test.tsx index 4d13c1f516..a250d28a1d 100644 --- a/src/__tests__/patients/list/ViewPatients.test.tsx +++ b/src/__tests__/patients/list/ViewPatients.test.tsx @@ -53,6 +53,18 @@ describe('Patients', () => { mockedPatientRepository.findAll.mockResolvedValue([]) }) + describe('initalLoad', () => { + afterEach(() => { + jest.restoreAllMocks() + }) + + it('should call fetchPatients only once', () => { + setup() + const findAllPagedSpy = jest.spyOn(PatientRepository, 'findAll') + expect(findAllPagedSpy).toHaveBeenCalledTimes(1) + }) + }) + describe('layout', () => { afterEach(() => { jest.restoreAllMocks() diff --git a/src/patients/list/ViewPatients.tsx b/src/patients/list/ViewPatients.tsx index 7682463e46..ba2c470013 100644 --- a/src/patients/list/ViewPatients.tsx +++ b/src/patients/list/ViewPatients.tsx @@ -6,7 +6,7 @@ import { Spinner, Button, Container, Row, TextInput, Column } from '@hospitalrun import { useButtonToolbarSetter } from 'page-header/ButtonBarProvider' import format from 'date-fns/format' import { RootState } from '../../store' -import { fetchPatients, searchPatients } from '../patients-slice' +import { searchPatients } from '../patients-slice' import useTitle from '../../page-header/useTitle' import useAddBreadcrumbs from '../../breadcrumbs/useAddBreadcrumbs' import useDebounce from '../../hooks/debounce' @@ -32,8 +32,6 @@ const ViewPatients = () => { }, [dispatch, debouncedSearchText]) useEffect(() => { - dispatch(fetchPatients()) - setButtonToolBar([