add frontend
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import WardTable from '@/components/ward/WardTable.vue'
|
||||
|
||||
const { mockPush } = vi.hoisted(() => ({
|
||||
mockPush: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
useRouter: () => ({ push: mockPush }),
|
||||
}))
|
||||
|
||||
const patients = [
|
||||
{
|
||||
encounterId: 'enc-1',
|
||||
firstName: 'Alice',
|
||||
lastName: 'A',
|
||||
mrn: 'M1',
|
||||
room: '101',
|
||||
news2Score: 3,
|
||||
qsofaScore: 0,
|
||||
sepsisActive: false,
|
||||
openAlertCount: 0,
|
||||
},
|
||||
{
|
||||
encounterId: 'enc-2',
|
||||
firstName: 'Bob',
|
||||
lastName: 'B',
|
||||
mrn: 'M2',
|
||||
room: '102',
|
||||
news2Score: 5,
|
||||
qsofaScore: 1,
|
||||
sepsisActive: false,
|
||||
openAlertCount: 1,
|
||||
},
|
||||
{
|
||||
encounterId: 'enc-3',
|
||||
firstName: 'Carol',
|
||||
lastName: 'C',
|
||||
mrn: 'M3',
|
||||
room: '103',
|
||||
news2Score: 8,
|
||||
qsofaScore: 2,
|
||||
sepsisActive: true,
|
||||
openAlertCount: 3,
|
||||
},
|
||||
]
|
||||
|
||||
describe('WardTable', () => {
|
||||
it('rendersAllPatientRows', () => {
|
||||
const wrapper = mount(WardTable, { props: { patients } })
|
||||
expect(wrapper.findAll('tbody tr')).toHaveLength(3)
|
||||
})
|
||||
|
||||
it('emitsClickWithEncounterId', async () => {
|
||||
mockPush.mockClear()
|
||||
const wrapper = mount(WardTable, { props: { patients } })
|
||||
await wrapper.findAll('tbody tr')[2].trigger('click')
|
||||
expect(mockPush).toHaveBeenCalledWith({
|
||||
name: 'PatientDetail',
|
||||
params: { encounterId: 'enc-3' },
|
||||
})
|
||||
})
|
||||
|
||||
it('showsCriticalBadgeForHighNews2', () => {
|
||||
const wrapper = mount(WardTable, { props: { patients } })
|
||||
const highRiskRow = wrapper.findAll('tbody tr')[2]
|
||||
expect(highRiskRow.html()).toContain('text-severity-critical')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user