feat(gui-v2): EnergyPicker interactive 5-step (crewli-starter port) + story

This commit is contained in:
2026-05-18 11:25:27 +02:00
parent 79650d0b72
commit 91d20d0dd2
3 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
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)
})
})