Files
sensor-web-v2/tests/components/TimeWindows.test.ts
Marco Crapts 27cda7f222
All checks were successful
continuous-integration/drone/push Build is passing
upgrade to Vue 3.4.3
2024-01-02 22:33:03 +01:00

32 lines
996 B
TypeScript

import { expect, test, describe } from 'vitest'
import { shallowMount } from '@vue/test-utils'
import TimeWindows from '@/components/TimeWindows.vue'
import type { Window } from '@/utils/types'
import { windows } from '@/utils/helpers'
const getWrapper = () => {
return shallowMount(TimeWindows, {
props: {
modelValue: windows[1],
windows
}
})
}
describe('TimeWindows', () => {
test('renders time windows correctly', () => {
const wrapper = getWrapper()
const listItems = wrapper.findAll('li')
expect(listItems[0]?.text()).toContain(windows[0].label)
expect(listItems[1]?.classes('is-active')).toBe(true)
})
test('emits an event when a time window is clicked', async () => {
const wrapper = getWrapper()
const listItems = wrapper.findAll('li')
await listItems[0]?.trigger('click')
const selectedWindow = (wrapper.emitted('update:modelValue') || [])[0][0] as Window
expect(selectedWindow.label).toEqual('afgelopen uur')
})
})