diff --git a/src/__tests__/patients/allergies/Allergies.test.tsx b/src/__tests__/patients/allergies/Allergies.test.tsx index 2bed7d2705..6f1a1029ec 100644 --- a/src/__tests__/patients/allergies/Allergies.test.tsx +++ b/src/__tests__/patients/allergies/Allergies.test.tsx @@ -9,7 +9,6 @@ import thunk from 'redux-thunk' import { Router } from 'react-router' import { Provider } from 'react-redux' import Patient from 'model/Patient' -import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components' import * as components from '@hospitalrun/components' import { act } from '@testing-library/react' import { mocked } from 'ts-jest/utils' @@ -56,7 +55,7 @@ describe('Allergies', () => { it('should render a button to add new allergies', () => { const wrapper = setup() - const addAllergyButton = wrapper.find(Button) + const addAllergyButton = wrapper.find(components.Button) expect(addAllergyButton).toHaveLength(1) expect(addAllergyButton.text().trim()).toEqual('patient.allergies.new') }) @@ -64,7 +63,7 @@ describe('Allergies', () => { it('should not render a button to add new allergies if the user does not have permissions', () => { const wrapper = setup(expectedPatient, []) - const addAllergyButton = wrapper.find(Button) + const addAllergyButton = wrapper.find(components.Button) expect(addAllergyButton).toHaveLength(0) }) @@ -72,14 +71,14 @@ describe('Allergies', () => { const wrapper = setup() act(() => { - const addAllergyButton = wrapper.find(Button) + const addAllergyButton = wrapper.find(components.Button) const onClick = addAllergyButton.prop('onClick') as any onClick({} as React.MouseEvent) }) wrapper.update() - expect(wrapper.find(Modal).prop('show')).toBeTruthy() + expect(wrapper.find(components.Modal).prop('show')).toBeTruthy() }) it('should update the patient with the new allergy when the save button is clicked', async () => { @@ -139,8 +138,8 @@ describe('Allergies', () => { const allergies = expectedPatient.allergies as Allergy[] const wrapper = setup() - const list = wrapper.find(List) - const listItems = wrapper.find(ListItem) + const list = wrapper.find(components.List) + const listItems = wrapper.find(components.ListItem) expect(list).toHaveLength(1) expect(listItems).toHaveLength(allergies.length) @@ -149,7 +148,7 @@ describe('Allergies', () => { it('should render a warning message if the patient does not have any allergies', () => { const wrapper = setup({ ...expectedPatient, allergies: [] }) - const alert = wrapper.find(Alert) + const alert = wrapper.find(components.Alert) expect(alert).toHaveLength(1) expect(alert.prop('title')).toEqual('patient.allergies.warning.noAllergies') diff --git a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx index c31af99c86..07db29610a 100644 --- a/src/__tests__/patients/diagnoses/Diagnoses.test.tsx +++ b/src/__tests__/patients/diagnoses/Diagnoses.test.tsx @@ -10,7 +10,6 @@ import Permissions from 'model/Permissions' import { Router } from 'react-router' import { Provider } from 'react-redux' import Diagnoses from 'patients/diagnoses/Diagnoses' -import { Button, Modal, List, ListItem, Alert } from '@hospitalrun/components' import * as components from '@hospitalrun/components' import { act } from 'react-dom/test-utils' import { mocked } from 'ts-jest/utils' @@ -54,7 +53,7 @@ describe('Diagnoses', () => { it('should render a add diagnoses button', () => { const wrapper = setup() - const addDiagnosisButton = wrapper.find(Button) + const addDiagnosisButton = wrapper.find(components.Button) expect(addDiagnosisButton).toHaveLength(1) expect(addDiagnosisButton.text().trim()).toEqual('patient.diagnoses.new') }) @@ -62,7 +61,7 @@ describe('Diagnoses', () => { it('should not render a diagnoses button if the user does not have permissions', () => { const wrapper = setup(expectedPatient, []) - const addDiagnosisButton = wrapper.find(Button) + const addDiagnosisButton = wrapper.find(components.Button) expect(addDiagnosisButton).toHaveLength(0) }) @@ -70,11 +69,11 @@ describe('Diagnoses', () => { const wrapper = setup() act(() => { - wrapper.find(Button).prop('onClick')() + wrapper.find(components.Button).prop('onClick')() }) wrapper.update() - expect(wrapper.find(Modal).prop('show')).toBeTruthy() + expect(wrapper.find(components.Modal).prop('show')).toBeTruthy() }) it('should update the patient with the new diagnosis when the save button is clicked', async () => { @@ -140,8 +139,8 @@ describe('Diagnoses', () => { const diagnoses = expectedPatient.diagnoses as Diagnosis[] const wrapper = setup() - const list = wrapper.find(List) - const listItems = wrapper.find(ListItem) + const list = wrapper.find(components.List) + const listItems = wrapper.find(components.ListItem) expect(list).toHaveLength(1) expect(listItems).toHaveLength(diagnoses.length) @@ -150,7 +149,7 @@ describe('Diagnoses', () => { it('should render a warning message if the patient does not have any diagnoses', () => { const wrapper = setup({ ...expectedPatient, diagnoses: [] }) - const alert = wrapper.find(Alert) + const alert = wrapper.find(components.Alert) expect(alert).toHaveLength(1) expect(alert.prop('title')).toEqual('patient.diagnoses.warning.noDiagnoses') diff --git a/src/__tests__/patients/new/NewPatient.test.tsx b/src/__tests__/patients/new/NewPatient.test.tsx index bc9ee4b051..6a346cb0e8 100644 --- a/src/__tests__/patients/new/NewPatient.test.tsx +++ b/src/__tests__/patients/new/NewPatient.test.tsx @@ -6,7 +6,6 @@ import { Provider } from 'react-redux' import { mocked } from 'ts-jest/utils' import { createMemoryHistory } from 'history' import { act } from 'react-dom/test-utils' -import { Button } from '@hospitalrun/components' import configureMockStore, { MockStore } from 'redux-mock-store' import thunk from 'redux-thunk' import * as components from '@hospitalrun/components' @@ -86,7 +85,7 @@ describe('New Patient', () => { const generalInformationForm = wrapper.find(GeneralInformation) expect(generalInformationForm.prop('errorMessage')).toBe('') - const saveButton = wrapper.find(Button).at(0) + const saveButton = wrapper.find(components.Button).at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -114,7 +113,7 @@ describe('New Patient', () => { wrapper.update() - const saveButton = wrapper.find(Button).at(0) + const saveButton = wrapper.find(components.Button).at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -143,7 +142,7 @@ describe('New Patient', () => { wrapper.update() - const saveButton = wrapper.find(Button).at(0) + const saveButton = wrapper.find(components.Button).at(0) const onClick = saveButton.prop('onClick') as any expect(saveButton.text().trim()).toEqual('actions.save') @@ -165,7 +164,7 @@ describe('New Patient', () => { wrapper = await setup() }) - const cancelButton = wrapper.find(Button).at(1) + const cancelButton = wrapper.find(components.Button).at(1) const onClick = cancelButton.prop('onClick') as any expect(cancelButton.text().trim()).toEqual('actions.cancel') diff --git a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx index 97b3aba0db..44948957e5 100644 --- a/src/__tests__/patients/related-persons/RelatedPersons.test.tsx +++ b/src/__tests__/patients/related-persons/RelatedPersons.test.tsx @@ -4,7 +4,6 @@ import { Router } from 'react-router' import { createMemoryHistory } from 'history' import { mount } from 'enzyme' import RelatedPersonTab from 'patients/related-persons/RelatedPersonTab' -import { Button, List, ListItem, Alert } from '@hospitalrun/components' import * as components from '@hospitalrun/components' import NewRelatedPersonModal from 'patients/related-persons/NewRelatedPersonModal' @@ -56,7 +55,7 @@ describe('Related Persons Tab', () => { }) it('should render a New Related Person button', () => { - const newRelatedPersonButton = wrapper.find(Button) + const newRelatedPersonButton = wrapper.find(components.Button) expect(newRelatedPersonButton).toHaveLength(1) expect(newRelatedPersonButton.text().trim()).toEqual('patient.relatedPersons.new') @@ -73,7 +72,7 @@ describe('Related Persons Tab', () => { , ) }) - const newRelatedPersonButton = wrapper.find(Button) + const newRelatedPersonButton = wrapper.find(components.Button) expect(newRelatedPersonButton).toHaveLength(0) }) @@ -85,7 +84,7 @@ describe('Related Persons Tab', () => { }) it('should show the New Related Person modal when the New Related Person button is clicked', () => { - const newRelatedPersonButton = wrapper.find(Button) + const newRelatedPersonButton = wrapper.find(components.Button) act(() => { ;(newRelatedPersonButton.prop('onClick') as any)() @@ -118,7 +117,7 @@ describe('Related Persons Tab', () => { ) }) act(() => { - const newRelatedPersonButton = wrapper.find(Button) + const newRelatedPersonButton = wrapper.find(components.Button) const onClick = newRelatedPersonButton.prop('onClick') as any onClick() }) @@ -138,7 +137,7 @@ describe('Related Persons Tab', () => { it('should close the modal when the save button is clicked', () => { act(() => { - const newRelatedPersonButton = wrapper.find(Button) + const newRelatedPersonButton = wrapper.find(components.Button) const onClick = newRelatedPersonButton.prop('onClick') as any onClick() }) @@ -204,15 +203,15 @@ describe('Related Persons Tab', () => { }) it('should render a list of related persons with their full name being displayed', () => { - const list = wrapper.find(List) - const listItems = wrapper.find(ListItem) + const list = wrapper.find(components.List) + const listItems = wrapper.find(components.ListItem) expect(list).toHaveLength(1) expect(listItems).toHaveLength(1) expect(listItems.at(0).text()).toEqual('test test') }) it('should navigate to related person patient profile on related person click', () => { - const list = wrapper.find(List) - const listItems = wrapper.find(ListItem) + const list = wrapper.find(components.List) + const listItems = wrapper.find(components.ListItem) act(() => { ;(listItems.at(0).prop('onClick') as any)() }) @@ -252,7 +251,7 @@ describe('Related Persons Tab', () => { }) it('should display a warning if patient has no related persons', () => { - const warning = wrapper.find(Alert) + const warning = wrapper.find(components.Alert) expect(warning).toBeDefined() }) }) diff --git a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx index 7eabf0cfb8..7a976a11d0 100644 --- a/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx +++ b/src/__tests__/scheduling/appointments/view/ViewAppointment.test.tsx @@ -11,7 +11,6 @@ import { createMemoryHistory } from 'history' import AppointmentRepository from 'clients/db/AppointmentRepository' import { mocked } from 'ts-jest/utils' import { act } from 'react-dom/test-utils' -import { Spinner, Modal } from '@hospitalrun/components' import * as components from '@hospitalrun/components' import AppointmentDetailForm from 'scheduling/appointments/AppointmentDetailForm' import PatientRepository from 'clients/db/PatientRepository' @@ -145,7 +144,7 @@ describe('View Appointment', () => { wrapper = await setup(true) }) - expect(wrapper.find(Spinner)).toHaveLength(1) + expect(wrapper.find(components.Spinner)).toHaveLength(1) }) it('should render a AppointmentDetailForm with the correct data', async () => { @@ -165,7 +164,7 @@ describe('View Appointment', () => { wrapper = await setup(false) }) - const deleteAppointmentConfirmationModal = wrapper.find(Modal) + const deleteAppointmentConfirmationModal = wrapper.find(components.Modal) expect(deleteAppointmentConfirmationModal).toHaveLength(1) expect(deleteAppointmentConfirmationModal.prop('closeButton').children).toEqual( 'actions.delete', @@ -214,7 +213,7 @@ describe('View Appointment', () => { }) wrapper.update() - const deleteConfirmationModal = wrapper.find(Modal) + const deleteConfirmationModal = wrapper.find(components.Modal) expect(deleteConfirmationModal.prop('show')).toEqual(true) }) @@ -234,12 +233,12 @@ describe('View Appointment', () => { wrapper.update() act(() => { - const deleteConfirmationModal = wrapper.find(Modal) + const deleteConfirmationModal = wrapper.find(components.Modal) deleteConfirmationModal.prop('toggle')() }) wrapper.update() - const deleteConfirmationModal = wrapper.find(Modal) + const deleteConfirmationModal = wrapper.find(components.Modal) expect(deleteConfirmationModal.prop('show')).toEqual(false) }) @@ -249,7 +248,7 @@ describe('View Appointment', () => { wrapper = await setup(false, [Permissions.ReadAppointments, Permissions.DeleteAppointment]) }) - const deleteConfirmationModal = wrapper.find(Modal) + const deleteConfirmationModal = wrapper.find(components.Modal) await act(async () => { await deleteConfirmationModal.prop('closeButton').onClick() @@ -272,7 +271,7 @@ describe('View Appointment', () => { wrapper = await setup(false, [Permissions.ReadAppointments, Permissions.DeleteAppointment]) }) - const deleteConfirmationModal = wrapper.find(Modal) + const deleteConfirmationModal = wrapper.find(components.Modal) await act(async () => { await deleteConfirmationModal.prop('closeButton').onClick()