Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
fix: fix multiple imports lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmeyer committed Mar 5, 2020
1 parent c077d75 commit e1e1f4c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 40 deletions.
15 changes: 7 additions & 8 deletions src/__tests__/patients/allergies/Allergies.test.tsx
Expand Up @@ -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'
Expand Down Expand Up @@ -56,30 +55,30 @@ 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')
})

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)
})

it('should open the New Allergy Modal when clicked', () => {
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<HTMLButtonElement>)
})

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 () => {
Expand Down Expand Up @@ -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)
Expand All @@ -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')
Expand Down
15 changes: 7 additions & 8 deletions src/__tests__/patients/diagnoses/Diagnoses.test.tsx
Expand Up @@ -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'
Expand Down Expand Up @@ -54,27 +53,27 @@ 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')
})

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)
})

it('should open the Add Diagnosis Modal', () => {
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 () => {
Expand Down Expand Up @@ -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)
Expand All @@ -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')
Expand Down
9 changes: 4 additions & 5 deletions src/__tests__/patients/new/NewPatient.test.tsx
Expand Up @@ -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'
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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')

Expand All @@ -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')

Expand Down
21 changes: 10 additions & 11 deletions src/__tests__/patients/related-persons/RelatedPersons.test.tsx
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -73,7 +72,7 @@ describe('Related Persons Tab', () => {
</Router>,
)
})
const newRelatedPersonButton = wrapper.find(Button)
const newRelatedPersonButton = wrapper.find(components.Button)
expect(newRelatedPersonButton).toHaveLength(0)
})

Expand All @@ -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)()
Expand Down Expand Up @@ -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()
})
Expand All @@ -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()
})
Expand Down Expand Up @@ -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)()
})
Expand Down Expand Up @@ -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()
})
})
Expand Down
Expand Up @@ -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'
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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',
Expand Down Expand Up @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit e1e1f4c

Please sign in to comment.