Files
vigilcare-clinical/vigilcare-dashboard/src/__tests__/DepartmentOverviewView.test.js
T

55 lines
1.4 KiB
JavaScript

import { describe, it, expect, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
import DepartmentOverviewView from '@/views/DepartmentOverviewView.vue'
const { mockPush } = vi.hoisted(() => ({
mockPush: vi.fn(),
}))
vi.mock('vue-router', () => ({
useRouter: () => ({ push: mockPush }),
}))
vi.mock('@/composables/usePolling', () => ({
usePolling: (fn) => {
fn()
},
}))
vi.mock('@/api/encounters', () => ({
fetchAllActiveEncounters: vi.fn(() => Promise.resolve([
{
department: 'ICU',
news2Score: 8,
openAlertCount: 2,
sepsisActive: true,
sepsisBundleStatus: 'IN_PROGRESS',
},
{
department: 'GENERAL_MEDICINE',
news2Score: 3,
openAlertCount: 0,
sepsisActive: false,
},
])),
}))
vi.mock('@/api/analytics', () => ({
fetchAlertSummary: vi.fn(() => Promise.resolve({
summary: [{ department: 'ICU', total: 5 }],
})),
}))
describe('DepartmentOverviewView', () => {
it('rendersDepartmentCardsAndTotals', async () => {
setActivePinia(createPinia())
const wrapper = mount(DepartmentOverviewView)
await vi.waitFor(() => expect(wrapper.text()).toContain('1 active patient'))
expect(wrapper.text()).toContain('Department Overview')
expect(wrapper.text()).toContain('Critical (NEWS2 ≥ 7)')
expect(wrapper.text()).toContain('Alert volume')
})
})