Files
waveform-analysis/src/views/FixedYDomainDemo.test.ts
李启源 a12002ba11
All checks were successful
Package component / package (push) Successful in 9m22s
feat(chart): support fixed y-axis domains
2026-07-29 15:50:25 +08:00

45 lines
1.3 KiB
TypeScript

import { flushPromises, mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import { WaveformChart } from '../components'
import { routes } from '../router'
import FixedYDomainDemo from './FixedYDomainDemo.vue'
describe('fixed Y-domain demo route', () => {
it('registers the example route', () => {
expect(routes).toEqual(
expect.arrayContaining([
expect.objectContaining({
path: '/fixed-y-domain',
name: 'fixed-y-domain',
}),
]),
)
})
it('switches between global, automatic, and per-channel ranges', async () => {
const wrapper = mount(FixedYDomainDemo)
await flushPromises()
const chart = () => wrapper.getComponent(WaveformChart)
const modeInputs = wrapper.get('[aria-label="Y 轴范围模式"]').findAll('input[type="radio"]')
expect(chart().props('yDomain')).toEqual([-80, 80])
expect(chart().props('yDomains')).toBeUndefined()
await modeInputs[0]?.setValue(true)
await flushPromises()
expect(chart().props('yDomain')).toBeUndefined()
expect(chart().props('yDomains')).toBeUndefined()
await modeInputs[2]?.setValue(true)
await flushPromises()
expect(chart().props('yDomain')).toBeUndefined()
expect(chart().props('yDomains')).toEqual({
voltage: [-65, 65],
current: [-260, 260],
})
wrapper.unmount()
})
})