26 lines
930 B
TypeScript
26 lines
930 B
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { describe, expect, it } from 'vitest'
|
|
import EnergyPicker from '@/components-v2/shared/EnergyPicker.vue'
|
|
|
|
describe('EnergyPicker', () => {
|
|
it('renders 5 buttons; clicking i emits i', async () => {
|
|
const w = mount(EnergyPicker, { props: { modelValue: 0 } })
|
|
const btns = w.findAll('button')
|
|
|
|
expect(btns).toHaveLength(5)
|
|
await btns[2].trigger('click')
|
|
expect(w.emitted('update:modelValue')![0]).toEqual([3])
|
|
})
|
|
it('clicking the current value toggles back to 0 (crewli-starter parity)', async () => {
|
|
const w = mount(EnergyPicker, { props: { modelValue: 3 } })
|
|
|
|
await w.findAll('button')[2].trigger('click')
|
|
expect(w.emitted('update:modelValue')![0]).toEqual([0])
|
|
})
|
|
it('marks buttons up to modelValue as on', () => {
|
|
const w = mount(EnergyPicker, { props: { modelValue: 2 } })
|
|
|
|
expect(w.findAll('button.on')).toHaveLength(2)
|
|
})
|
|
})
|