@oanda/labs-crowd-view-widget 1.0.54 → 1.0.55
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.
- package/CHANGELOG.md +224 -0
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js +37 -56
- package/dist/main/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js +20 -7
- package/dist/main/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +15 -9
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +6 -6
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +41 -13
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +159 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +7 -14
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +20 -2
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +13 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +10 -3
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +20 -5
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +19 -28
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +18 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +1 -20
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +21 -9
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +59 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +34 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js +33 -0
- package/dist/main/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js +19 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js +11 -0
- package/dist/main/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js +33 -21
- package/dist/main/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +7 -4
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +11 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +13 -5
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +0 -6
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/main/translations/sources/en.json +2 -1
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js +38 -56
- package/dist/module/CrowdViewWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js +19 -6
- package/dist/module/CrowdViewWidget/components/Chart/ChartWithData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js +15 -9
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js +6 -6
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js +41 -13
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getGridLines.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js +151 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js +7 -14
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js +20 -2
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js +13 -5
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js +10 -3
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js +21 -6
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js +19 -28
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js +11 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js +1 -20
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getLabelData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js +21 -9
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js +52 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js +27 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js +3 -0
- package/dist/module/CrowdViewWidget/components/Chart/chartUtils/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js +12 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.js.map +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js +1 -0
- package/dist/module/CrowdViewWidget/components/Chart/dataUtils/index.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js +34 -22
- package/dist/module/CrowdViewWidget/components/Chart/getOption.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +8 -5
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +11 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +13 -5
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +0 -6
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/translations/sources/en.json +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.d.ts +5 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getGridLines.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.d.ts +8 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.d.ts +2 -3
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.d.ts +3 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.d.ts +1 -3
- package/dist/types/CrowdViewWidget/components/Chart/chartOptions/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getLabelData.d.ts +1 -16
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.d.ts +3 -1
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.d.ts +4 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.d.ts +3 -0
- package/dist/types/CrowdViewWidget/components/Chart/chartUtils/index.d.ts +3 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.d.ts +2 -0
- package/dist/types/CrowdViewWidget/components/Chart/dataUtils/index.d.ts +1 -0
- package/dist/types/CrowdViewWidget/components/Chart/types.d.ts +5 -0
- package/dist/types/CrowdViewWidget/constants.d.ts +12 -4
- package/package.json +3 -3
- package/src/CrowdViewWidget/components/Chart/Chart.tsx +70 -79
- package/src/CrowdViewWidget/components/Chart/ChartWithData.tsx +31 -13
- package/src/CrowdViewWidget/components/Chart/chartOptions/getDataZoomConfig.ts +11 -2
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridConfig.ts +6 -6
- package/src/CrowdViewWidget/components/Chart/chartOptions/getGridLines.ts +48 -6
- package/src/CrowdViewWidget/components/Chart/chartOptions/getLabelsConfig.ts +191 -0
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesCandlestickConfig.ts +7 -15
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesHeatmapConfig.ts +22 -1
- package/src/CrowdViewWidget/components/Chart/chartOptions/getSeriesSentimentConfig.ts +13 -4
- package/src/CrowdViewWidget/components/Chart/chartOptions/getTooltipConfig.ts +12 -1
- package/src/CrowdViewWidget/components/Chart/chartOptions/getXAxisConfig.ts +55 -30
- package/src/CrowdViewWidget/components/Chart/chartOptions/getYAxisConfig.ts +13 -30
- package/src/CrowdViewWidget/components/Chart/chartOptions/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/formatXAxisAdditionalLabel.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/getLabelData.ts +11 -35
- package/src/CrowdViewWidget/components/Chart/chartUtils/getTooltipFormatter.ts +40 -11
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleLabelUpdate.ts +75 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate.ts +37 -0
- package/src/CrowdViewWidget/components/Chart/chartUtils/index.ts +3 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/getMultiplayerForTimeSpan.ts +13 -0
- package/src/CrowdViewWidget/components/Chart/dataUtils/index.ts +1 -0
- package/src/CrowdViewWidget/components/Chart/getOption.ts +41 -17
- package/src/CrowdViewWidget/components/Chart/types.ts +5 -0
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +12 -5
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +1 -1
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +17 -1
- package/src/CrowdViewWidget/constants.ts +12 -4
- package/src/CrowdViewWidget/selectConfig.ts +0 -8
- package/src/translations/sources/en.json +2 -1
- package/test/components/Chart/utils/chartUtils.test.ts +13 -2
- package/test/components/Chart/utils/handleLabelUpdate.test.ts +419 -0
- package/test/components/Chart/utils/handleTooltipUpdate.test.ts +140 -0
- package/test/components/Legend.test.tsx +3 -3
- package/test/components/LegendBar.test.tsx +22 -20
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { EChartsType } from 'echarts';
|
|
2
|
+
|
|
3
|
+
import { handleTooltipUpdate } from '../../../../src/CrowdViewWidget/components/Chart/chartUtils/handleTooltipUpdate';
|
|
4
|
+
|
|
5
|
+
describe('handleTooltipUpdate', () => {
|
|
6
|
+
let mockInstance: jest.Mocked<EChartsType>;
|
|
7
|
+
let zoomTimerRef: { current: NodeJS.Timeout | null };
|
|
8
|
+
let tooltipVisibleRef: { current: boolean };
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
jest.useFakeTimers();
|
|
12
|
+
jest.clearAllMocks();
|
|
13
|
+
|
|
14
|
+
mockInstance = {
|
|
15
|
+
setOption: jest.fn(),
|
|
16
|
+
} as unknown as jest.Mocked<EChartsType>;
|
|
17
|
+
|
|
18
|
+
zoomTimerRef = { current: null };
|
|
19
|
+
tooltipVisibleRef = { current: true };
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
jest.runOnlyPendingTimers();
|
|
24
|
+
jest.useRealTimers();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('when canHover is false', () => {
|
|
28
|
+
it('should not hide tooltip on touch devices', () => {
|
|
29
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, false);
|
|
30
|
+
|
|
31
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
32
|
+
expect(tooltipVisibleRef.current).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('when canHover is true', () => {
|
|
37
|
+
it('should hide tooltip immediately when visible', () => {
|
|
38
|
+
tooltipVisibleRef.current = true;
|
|
39
|
+
|
|
40
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
41
|
+
|
|
42
|
+
expect(mockInstance.setOption).toHaveBeenCalledWith({
|
|
43
|
+
tooltip: {
|
|
44
|
+
show: false,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
expect(tooltipVisibleRef.current).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should not call setOption when tooltip is already hidden', () => {
|
|
51
|
+
tooltipVisibleRef.current = false;
|
|
52
|
+
|
|
53
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
54
|
+
|
|
55
|
+
expect(mockInstance.setOption).not.toHaveBeenCalled();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should clear existing timeout before setting new one', () => {
|
|
59
|
+
const existingTimeout = setTimeout(() => {}, 1000);
|
|
60
|
+
zoomTimerRef.current = existingTimeout;
|
|
61
|
+
const clearTimeoutSpy = jest.spyOn(global, 'clearTimeout');
|
|
62
|
+
|
|
63
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
64
|
+
|
|
65
|
+
expect(clearTimeoutSpy).toHaveBeenCalledWith(existingTimeout);
|
|
66
|
+
clearTimeoutSpy.mockRestore();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should show tooltip after 100ms delay', () => {
|
|
70
|
+
tooltipVisibleRef.current = true;
|
|
71
|
+
|
|
72
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
73
|
+
|
|
74
|
+
// Tooltip should be hidden immediately
|
|
75
|
+
expect(tooltipVisibleRef.current).toBe(false);
|
|
76
|
+
expect(mockInstance.setOption).toHaveBeenCalledWith({
|
|
77
|
+
tooltip: {
|
|
78
|
+
show: false,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Fast-forward time
|
|
83
|
+
jest.advanceTimersByTime(100);
|
|
84
|
+
|
|
85
|
+
// Tooltip should be shown again
|
|
86
|
+
expect(mockInstance.setOption).toHaveBeenCalledWith({
|
|
87
|
+
tooltip: {
|
|
88
|
+
show: true,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
expect(tooltipVisibleRef.current).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should not show tooltip if it was already shown during timeout', () => {
|
|
95
|
+
tooltipVisibleRef.current = true;
|
|
96
|
+
|
|
97
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
98
|
+
|
|
99
|
+
// Manually set tooltip to visible before timeout
|
|
100
|
+
tooltipVisibleRef.current = true;
|
|
101
|
+
|
|
102
|
+
jest.advanceTimersByTime(100);
|
|
103
|
+
|
|
104
|
+
// Should not call setOption to show tooltip since it's already visible
|
|
105
|
+
const { calls } = mockInstance.setOption.mock;
|
|
106
|
+
expect(calls.length).toBe(1); // Only the hide call
|
|
107
|
+
expect(calls[0][0]).toEqual({
|
|
108
|
+
tooltip: {
|
|
109
|
+
show: false,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should reset timeout on subsequent calls', () => {
|
|
115
|
+
tooltipVisibleRef.current = true;
|
|
116
|
+
|
|
117
|
+
// First call
|
|
118
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
119
|
+
const firstTimeout = zoomTimerRef.current;
|
|
120
|
+
|
|
121
|
+
// Second call before timeout
|
|
122
|
+
jest.advanceTimersByTime(50);
|
|
123
|
+
handleTooltipUpdate(mockInstance, zoomTimerRef, tooltipVisibleRef, true);
|
|
124
|
+
const secondTimeout = zoomTimerRef.current;
|
|
125
|
+
|
|
126
|
+
// Timeouts should be different
|
|
127
|
+
expect(firstTimeout).not.toBe(secondTimeout);
|
|
128
|
+
|
|
129
|
+
// Fast-forward 100ms from second call (150ms total)
|
|
130
|
+
jest.advanceTimersByTime(100);
|
|
131
|
+
|
|
132
|
+
// Should only show tooltip once (from second call)
|
|
133
|
+
const showCalls = mockInstance.setOption.mock.calls.filter(
|
|
134
|
+
(call) =>
|
|
135
|
+
(call[0] as { tooltip?: { show: boolean } }).tooltip?.show === true
|
|
136
|
+
);
|
|
137
|
+
expect(showCalls.length).toBe(1);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
@@ -21,7 +21,7 @@ describe('Crowd View Widget', () => {
|
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
const segments = getAllByTestId('legend-bar-segment');
|
|
24
|
-
expect(segments.length).toBe(
|
|
24
|
+
expect(segments.length).toBe(4);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('passes isDark prop to LegendBar components in light mode', () => {
|
|
@@ -31,7 +31,7 @@ describe('Crowd View Widget', () => {
|
|
|
31
31
|
</MockLayoutProvider>
|
|
32
32
|
);
|
|
33
33
|
const segments = getAllByTestId('legend-bar-segment');
|
|
34
|
-
expect(segments.length).toBe(
|
|
34
|
+
expect(segments.length).toBe(4);
|
|
35
35
|
// Check that segments use light mode colors (either long or short)
|
|
36
36
|
const styles = segments.map((segment) => segment.getAttribute('style'));
|
|
37
37
|
const hasLightColors = styles.some(
|
|
@@ -49,7 +49,7 @@ describe('Crowd View Widget', () => {
|
|
|
49
49
|
</MockLayoutProvider>
|
|
50
50
|
);
|
|
51
51
|
const segments = getAllByTestId('legend-bar-segment');
|
|
52
|
-
expect(segments.length).toBe(
|
|
52
|
+
expect(segments.length).toBe(4);
|
|
53
53
|
// Check that segments use dark mode colors (either long or short)
|
|
54
54
|
const styles = segments.map((segment) => segment.getAttribute('style'));
|
|
55
55
|
const hasDarkColors = styles.some(
|
|
@@ -11,58 +11,60 @@ import { COLOR_MAP } from '../../src/CrowdViewWidget/constants';
|
|
|
11
11
|
describe('Crowd View Widget', () => {
|
|
12
12
|
describe('components', () => {
|
|
13
13
|
describe('<LegendBar />', () => {
|
|
14
|
-
it('renders exactly
|
|
14
|
+
it('renders exactly 2 segments', () => {
|
|
15
15
|
const { getAllByTestId } = render(
|
|
16
16
|
<LegendBar isDark={false} type="short" />
|
|
17
17
|
);
|
|
18
18
|
const segments = getAllByTestId('legend-bar-segment');
|
|
19
|
-
expect(segments.length).toBe(
|
|
19
|
+
expect(segments.length).toBe(2);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
it('uses light mode colors when isDark is false for long type', () => {
|
|
23
|
-
const {
|
|
23
|
+
const { getAllByTestId } = render(
|
|
24
24
|
<LegendBar isDark={false} type="long" />
|
|
25
25
|
);
|
|
26
|
-
const
|
|
27
|
-
const style =
|
|
26
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
27
|
+
const style = segments[0].getAttribute('style');
|
|
28
28
|
expect(style).toContain(COLOR_MAP.light.long[0]);
|
|
29
29
|
expect(style).toContain(COLOR_MAP.light.long[1]);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('uses dark mode colors when isDark is true for long type', () => {
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const { getAllByTestId } = render(
|
|
34
|
+
<LegendBar isDark={true} type="long" />
|
|
35
|
+
);
|
|
36
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
37
|
+
const style = segments[0].getAttribute('style');
|
|
36
38
|
expect(style).toContain(COLOR_MAP.dark.long[0]);
|
|
37
39
|
expect(style).toContain(COLOR_MAP.dark.long[1]);
|
|
38
40
|
});
|
|
39
41
|
|
|
40
42
|
it('uses light mode short colors when isDark is false', () => {
|
|
41
|
-
const {
|
|
43
|
+
const { getAllByTestId } = render(
|
|
42
44
|
<LegendBar isDark={false} type="short" />
|
|
43
45
|
);
|
|
44
|
-
const
|
|
45
|
-
const style =
|
|
46
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
47
|
+
const style = segments[0].getAttribute('style');
|
|
46
48
|
expect(style).toContain(COLOR_MAP.light.short[0]);
|
|
47
49
|
expect(style).toContain(COLOR_MAP.light.short[1]);
|
|
48
50
|
});
|
|
49
51
|
|
|
50
52
|
it('uses dark mode short colors when isDark is true', () => {
|
|
51
|
-
const {
|
|
53
|
+
const { getAllByTestId } = render(
|
|
52
54
|
<LegendBar isDark={true} type="short" />
|
|
53
55
|
);
|
|
54
|
-
const
|
|
55
|
-
const style =
|
|
56
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
57
|
+
const style = segments[0].getAttribute('style');
|
|
56
58
|
expect(style).toContain(COLOR_MAP.dark.short[0]);
|
|
57
59
|
expect(style).toContain(COLOR_MAP.dark.short[1]);
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
it('renders gradient with correct direction for long type', () => {
|
|
61
|
-
const {
|
|
63
|
+
const { getAllByTestId } = render(
|
|
62
64
|
<LegendBar isDark={false} type="long" />
|
|
63
65
|
);
|
|
64
|
-
const
|
|
65
|
-
const style =
|
|
66
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
67
|
+
const style = segments[0].getAttribute('style');
|
|
66
68
|
// Long type should use long[1] as start and long[0] as end
|
|
67
69
|
expect(style).toMatch(/linear-gradient\(90deg/);
|
|
68
70
|
expect(style).toContain(COLOR_MAP.light.long[1]);
|
|
@@ -70,11 +72,11 @@ describe('Crowd View Widget', () => {
|
|
|
70
72
|
});
|
|
71
73
|
|
|
72
74
|
it('renders gradient with correct direction for short type', () => {
|
|
73
|
-
const {
|
|
75
|
+
const { getAllByTestId } = render(
|
|
74
76
|
<LegendBar isDark={false} type="short" />
|
|
75
77
|
);
|
|
76
|
-
const
|
|
77
|
-
const style =
|
|
78
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
79
|
+
const style = segments[0].getAttribute('style');
|
|
78
80
|
// Short type should use short[0] as start and short[1] as end
|
|
79
81
|
expect(style).toMatch(/linear-gradient\(90deg/);
|
|
80
82
|
expect(style).toContain(COLOR_MAP.light.short[0]);
|