56 lines
1.4 KiB
JavaScript
56 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('patients')
|
|
expect(wrapper.text()).toContain('critical')
|
|
expect(wrapper.text()).toContain('Alert volume')
|
|
expect(wrapper.text()).toContain('Open in Virtual Ward')
|
|
})
|
|
})
|