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

Commit

Permalink
feat(labs): fix time related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmeyer committed Apr 3, 2020
1 parent f354c94 commit 94fa61a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/__tests__/labs/ViewLab.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as ButtonBarProvider from 'page-header/ButtonBarProvider'
import createMockStore from 'redux-mock-store'
import { Badge, Button, Alert } from '@hospitalrun/components'
import TextFieldWithLabelFormGroup from 'components/input/TextFieldWithLabelFormGroup'
import format from 'date-fns/format'
import * as titleUtil from '../../page-header/useTitle'
import ViewLab from '../../labs/ViewLab'

Expand Down Expand Up @@ -104,7 +105,9 @@ describe('View Labs', () => {
const requestedOnDiv = wrapper.find('.requested-on')
expect(requestedOnDiv.find('h4').text().trim()).toEqual('labs.lab.requestedOn')

expect(requestedOnDiv.find('h5').text().trim()).toEqual('2020-03-29 11:43 PM')
expect(requestedOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'),
)
})

it('should not display the completed date if the lab is not completed', async () => {
Expand Down Expand Up @@ -202,7 +205,9 @@ describe('View Labs', () => {

expect(canceledOnDiv.find('h4').text().trim()).toEqual('labs.lab.canceledOn')

expect(canceledOnDiv.find('h5').text().trim()).toEqual('2020-03-29 11:45 PM')
expect(canceledOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.canceledOn as string), 'yyyy-MM-dd hh:mm a'),
)
})

it('should not display update, complete, and cancel button if the lab is canceled', async () => {
Expand Down Expand Up @@ -251,7 +256,9 @@ describe('View Labs', () => {

expect(completedOnDiv.find('h4').text().trim()).toEqual('labs.lab.completedOn')

expect(completedOnDiv.find('h5').text().trim()).toEqual('2020-03-29 11:44 PM')
expect(completedOnDiv.find('h5').text().trim()).toEqual(
format(new Date(expectedLab.completedOn as string), 'yyyy-MM-dd hh:mm a'),
)
})

it('should not display update, complete, and cancel buttons if the lab is completed', async () => {
Expand Down
5 changes: 4 additions & 1 deletion src/__tests__/labs/ViewLabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Permissions from 'model/Permissions'
import { act } from '@testing-library/react'
import LabRepository from 'clients/db/LabRepository'
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'

Expand Down Expand Up @@ -139,7 +140,9 @@ describe('View Labs', () => {

expect(tableDataColumns.at(0).text().trim()).toEqual(expectedLab.type)

expect(tableDataColumns.at(1).text().trim()).toEqual('2020-03-29 11:43 PM')
expect(tableDataColumns.at(1).text().trim()).toEqual(
format(new Date(expectedLab.requestedOn), 'yyyy-MM-dd hh:mm a'),
)

expect(tableDataColumns.at(2).text().trim()).toEqual(expectedLab.status)
})
Expand Down

0 comments on commit 94fa61a

Please sign in to comment.