All checks were successful
continuous-integration/drone/push Build is passing
32 lines
996 B
TypeScript
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')
|
|
})
|
|
})
|