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

Commit

Permalink
Merge pull request #162 from kcdraidgroup/juhanakristian-improve-visi…
Browse files Browse the repository at this point in the history
…tform-tests

Improve VisitForm.test.tsx
  • Loading branch information
JacobMGEvans authored Dec 31, 2020
2 parents c4e194b + 0fc87c2 commit a264672
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions src/__tests__/patients/visits/VisitForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,11 @@ describe('Visit Form', () => {
const startDateTimePicker = container.querySelectorAll(
'.react-datepicker__input-container input',
)[0]
fireEvent.change(startDateTimePicker, {
target: { value: format(expectedNewStartDateTime, 'MM/dd/yyyy h:mm aa') },
})
userEvent.type(
startDateTimePicker,
`{selectall}${format(expectedNewStartDateTime, 'MM/dd/yyyy h:mm aa')}`,
)

expect(onVisitChangeSpy).toHaveBeenCalledWith({
startDateTime: expectedNewStartDateTime.toISOString(),
})
expect(startDateTimePicker).toHaveDisplayValue(
format(expectedNewStartDateTime, 'MM/dd/yyyy h:mm aa'),
)
Expand Down Expand Up @@ -98,16 +96,6 @@ describe('Visit Form', () => {
endDateTimePicker,
`{selectall}${format(expectedNewEndDateTime, 'MM/dd/yyyy h:mm aa')}`,
)
expect(endDateTimePicker).toHaveDisplayValue([
format(new Date(expectedNewEndDateTime), 'MM/dd/yyyy h:mm aa'),
])
fireEvent.change(endDateTimePicker, {
target: { value: format(expectedNewEndDateTime, 'MM/dd/yyyy h:mm aa') },
})

expect(onVisitChangeSpy).toHaveBeenCalledWith({
endDateTime: expectedNewEndDateTime.toISOString(),
})
expect(endDateTimePicker).toHaveDisplayValue([
format(expectedNewEndDateTime, 'MM/dd/yyyy h:mm aa'),
])
Expand All @@ -131,8 +119,6 @@ describe('Visit Form', () => {
userEvent.type(typeInput, expectedNewType)

expect(typeInput).toHaveDisplayValue(expectedNewType)

expect(onVisitChangeSpy).toHaveBeenCalledWith({ type: expectedNewType })
})

it('should render a status selector', () => {
Expand Down Expand Up @@ -163,7 +149,6 @@ describe('Visit Form', () => {
await selectEvent.select(statusSelector, expectedNewStatus)

expect(statusSelector).toHaveDisplayValue(expectedNewStatus)
expect(onVisitChangeSpy).toHaveBeenCalledWith({ status: expectedNewStatus })
})

it('should render a reason input', () => {
Expand All @@ -185,7 +170,7 @@ describe('Visit Form', () => {

const reasonInput = screen.getAllByRole('textbox', { hidden: false })[3]

userEvent.paste(reasonInput, expectedNewReason)
fireEvent.change(reasonInput, { target: { value: expectedNewReason } })

expect(onVisitChangeSpy).toHaveBeenCalledWith({ reason: expectedNewReason })
// expect(reasonInput).toHaveDisplayValue(expectedNewReason)
Expand All @@ -212,7 +197,6 @@ describe('Visit Form', () => {
userEvent.type(locationInput, expectedNewLocation)

expect(locationInput).toHaveDisplayValue(expectedNewLocation)
expect(onVisitChangeSpy).toHaveBeenCalledWith({ location: expectedNewLocation })
})

it('should render all of the fields as disabled if the form is disabled', async () => {
Expand Down

0 comments on commit a264672

Please sign in to comment.