waveform-analysis 0.1.59 → 0.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,103 @@
1
+ import { flushPromises } from '@vue/test-utils'
2
+ import { describe, expect, it } from 'vitest'
3
+
4
+ import { resizeObservers } from '../../test/setup'
5
+
6
+ import { mountSizedChart } from '../../test/waveformChart'
7
+
8
+ describe('WaveformChart Y-axis layout', () => {
9
+ it('applies the configured Y-axis split number', async () => {
10
+ const wrapper = await mountSizedChart(
11
+ {
12
+ kind: 'points',
13
+ points: [
14
+ { x: 0, y: 3 },
15
+ { x: 1, y: 97 },
16
+ ],
17
+ },
18
+ { axes: { y: { splitNumber: 5 } } },
19
+ )
20
+
21
+ expect(
22
+ wrapper
23
+ .get('.waveform-chart__axis--y')
24
+ .findAll('.tick text')
25
+ .map((tick) => tick.text()),
26
+ ).toEqual(['0', '25', '50', '75', '100'])
27
+ })
28
+
29
+ it('reserves the rendered endpoint label width across tracks, pages, and resizes', async () => {
30
+ const wrapper = await mountSizedChart(
31
+ {
32
+ kind: 'series',
33
+ series: ['WE_2M', 'IP_VV_2M', 'SX2_7_07', 'BT1_2M'].map((name, index) => ({
34
+ id: name,
35
+ name,
36
+ unit: 'V',
37
+ data: {
38
+ kind: 'points' as const,
39
+ points: [
40
+ { x: 0, y: -0.7434 - index },
41
+ { x: 1, y: -0.3434 - index },
42
+ ],
43
+ },
44
+ })),
45
+ },
46
+ {
47
+ axes: { y: { lineVisible: false, nice: false } },
48
+ grid: { rowCount: 1, columnCount: 1 },
49
+ },
50
+ )
51
+ const firstTrack = wrapper.get('.waveform-chart__track')
52
+
53
+ expect(wrapper.attributes('data-chart-left-margin')).toBe('100')
54
+ expect(firstTrack.attributes('data-y-axis-label-x')).toBe('-90')
55
+ expect(firstTrack.findAll('.waveform-chart__axis--y .tick text').at(-1)?.text()).toBe(
56
+ '(V) -0.3434',
57
+ )
58
+
59
+ resizeObservers.at(-1)?.resize(520, 280)
60
+ await flushPromises()
61
+ expect(wrapper.attributes('data-chart-left-margin')).toBe('100')
62
+ expect(wrapper.get('.waveform-chart__track').attributes('data-y-axis-label-x')).toBe('-90')
63
+
64
+ await wrapper.get('.ant-pagination-next button').trigger('click')
65
+ expect(wrapper.attributes('data-chart-left-margin')).toBe('100')
66
+ expect(wrapper.get('.waveform-chart__track').attributes('data-y-axis-label-x')).toBe('-90')
67
+ expect(wrapper.get('.waveform-chart__axis--y').findAll('.tick text').at(-1)?.text()).toBe(
68
+ '(V) -1.3434',
69
+ )
70
+ })
71
+
72
+ it('measures the compact-row unit label after omitting the top endpoint', async () => {
73
+ const wrapper = await mountSizedChart(
74
+ {
75
+ kind: 'series',
76
+ series: ['first', 'second'].map((id) => ({
77
+ id,
78
+ name: id,
79
+ unit: 'V',
80
+ data: {
81
+ kind: 'points' as const,
82
+ points: [
83
+ { x: 0, y: 0.12345 },
84
+ { x: 1, y: 100 },
85
+ ],
86
+ },
87
+ })),
88
+ },
89
+ {
90
+ displayMode: 'compact',
91
+ axes: { y: { nice: false } },
92
+ grid: { rowCount: 2, columnCount: 1 },
93
+ },
94
+ )
95
+ const tracks = wrapper.findAll('.waveform-chart__track')
96
+
97
+ expect(wrapper.attributes('data-chart-left-margin')).toBe('93')
98
+ expect(tracks[1]?.attributes('data-y-axis-label-x')).toBe('-83')
99
+ expect(tracks[1]?.findAll('.waveform-chart__axis--y .tick text').at(-1)?.text()).toBe(
100
+ '(V) 75.031',
101
+ )
102
+ })
103
+ })