feat(chart): support fixed y-axis domains
All checks were successful
Package component / package (push) Successful in 9m22s
All checks were successful
Package component / package (push) Successful in 9m22s
This commit is contained in:
44
src/views/FixedYDomainDemo.test.ts
Normal file
44
src/views/FixedYDomainDemo.test.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user