Files
sensor-web-v2/tests/components/TimeWindows.test.ts
Marco Crapts 2c1df319e6
All checks were successful
continuous-integration/drone/push Build is passing
update test command
2023-12-04 23:36:15 +01:00

32 lines
973 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: {
activeWindow: 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 event = (wrapper.emitted('set-window') || [])[0][0] as Window
expect(event.label).toEqual('afgelopen uur')
})
})