Vue 3 + Vite + Tailwind frontend, Fastify API server, execa shell bridge. All components built, server validated, 41 unit tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
import { describe, it, expect } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import ToolSelector from '../ToolSelector.vue'
|
|
|
|
describe('ToolSelector', () => {
|
|
it('renders four tool buttons', () => {
|
|
const wrapper = mount(ToolSelector)
|
|
expect(wrapper.findAll('button').length).toBe(4)
|
|
})
|
|
|
|
it('emits tool-config immediately with chafa as default', () => {
|
|
const wrapper = mount(ToolSelector)
|
|
const emitted = wrapper.emitted('tool-config')
|
|
expect(emitted).toBeTruthy()
|
|
expect(emitted[0][0].tool).toBe('chafa')
|
|
})
|
|
|
|
it('strips empty and false flag values before emitting', () => {
|
|
const wrapper = mount(ToolSelector)
|
|
const flags = wrapper.emitted('tool-config')[0][0].flags
|
|
const hasEmpty = Object.values(flags).some((v) => v === '' || v === false)
|
|
expect(hasEmpty).toBe(false)
|
|
})
|
|
|
|
it('switches active tool and emits updated tool-config', async () => {
|
|
const wrapper = mount(ToolSelector)
|
|
const buttons = wrapper.findAll('button')
|
|
await buttons[1].trigger('click') // jp2a
|
|
const emitted = wrapper.emitted('tool-config')
|
|
const latest = emitted[emitted.length - 1][0]
|
|
expect(latest.tool).toBe('jp2a')
|
|
})
|
|
|
|
it('preserves flags for a tool when switching away and back', async () => {
|
|
const wrapper = mount(ToolSelector)
|
|
const [chafaBtn, jp2aBtn] = wrapper.findAll('button')
|
|
|
|
// Set width on chafa via ChafaOptions input
|
|
const widthInput = wrapper.find('input[type="number"]')
|
|
await widthInput.setValue('120')
|
|
|
|
// Switch to jp2a and back
|
|
await jp2aBtn.trigger('click')
|
|
await chafaBtn.trigger('click')
|
|
|
|
const emitted = wrapper.emitted('tool-config')
|
|
const latest = emitted[emitted.length - 1][0]
|
|
expect(latest.flags.width).toBe('120')
|
|
})
|
|
})
|