@oanda/labs-crowd-view-widget 1.0.47 → 1.0.49
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 +396 -0
- package/dist/main/CrowdViewWidget/Main.js +4 -2
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +8 -3
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +4 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +9 -2
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +6 -6
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/Main.js +4 -2
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +9 -4
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +4 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +9 -2
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +6 -6
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +2 -1
- package/dist/types/CrowdViewWidget/constants.d.ts +8 -2
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +2 -2
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +15 -3
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +6 -2
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +11 -4
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +4 -0
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +4 -2
- package/src/CrowdViewWidget/constants.ts +10 -2
- package/src/CrowdViewWidget/selectConfig.ts +8 -8
- package/test/components/Chart/utils/chartUtils.test.ts +23 -6
- package/test/components/Legend.test.tsx +44 -0
- package/test/components/LegendBar.test.tsx +73 -2
|
@@ -6,6 +6,7 @@ import { render } from '@testing-library/react';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { LegendBar } from '../../src/CrowdViewWidget/components';
|
|
9
|
+
import { COLOR_MAP } from '../../src/CrowdViewWidget/constants';
|
|
9
10
|
|
|
10
11
|
describe('Crowd View Widget', () => {
|
|
11
12
|
describe('components', () => {
|
|
@@ -14,7 +15,12 @@ describe('Crowd View Widget', () => {
|
|
|
14
15
|
|
|
15
16
|
it('renders LegendBar with min and max values', () => {
|
|
16
17
|
const { getByText } = render(
|
|
17
|
-
<LegendBar
|
|
18
|
+
<LegendBar
|
|
19
|
+
isDark={false}
|
|
20
|
+
label="long"
|
|
21
|
+
type="long"
|
|
22
|
+
values={mockValues}
|
|
23
|
+
/>
|
|
18
24
|
);
|
|
19
25
|
|
|
20
26
|
expect(getByText('long')).toBeInTheDocument();
|
|
@@ -24,11 +30,76 @@ describe('Crowd View Widget', () => {
|
|
|
24
30
|
|
|
25
31
|
it('renders exactly 1 segment', () => {
|
|
26
32
|
const { getAllByTestId } = render(
|
|
27
|
-
<LegendBar
|
|
33
|
+
<LegendBar
|
|
34
|
+
isDark={false}
|
|
35
|
+
label="short"
|
|
36
|
+
type="short"
|
|
37
|
+
values={mockValues}
|
|
38
|
+
/>
|
|
28
39
|
);
|
|
29
40
|
const segments = getAllByTestId('legend-bar-segment');
|
|
30
41
|
expect(segments.length).toBe(1);
|
|
31
42
|
});
|
|
43
|
+
|
|
44
|
+
it('uses light mode colors when isDark is false', () => {
|
|
45
|
+
const { getByTestId } = render(
|
|
46
|
+
<LegendBar
|
|
47
|
+
isDark={false}
|
|
48
|
+
label="long"
|
|
49
|
+
type="long"
|
|
50
|
+
values={mockValues}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
const segment = getByTestId('legend-bar-segment');
|
|
54
|
+
const style = segment.getAttribute('style');
|
|
55
|
+
expect(style).toContain(COLOR_MAP.light.long[0]);
|
|
56
|
+
expect(style).toContain(COLOR_MAP.light.long[1]);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('uses dark mode colors when isDark is true', () => {
|
|
60
|
+
const { getByTestId } = render(
|
|
61
|
+
<LegendBar
|
|
62
|
+
isDark={true}
|
|
63
|
+
label="long"
|
|
64
|
+
type="long"
|
|
65
|
+
values={mockValues}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
const segment = getByTestId('legend-bar-segment');
|
|
69
|
+
const style = segment.getAttribute('style');
|
|
70
|
+
expect(style).toContain(COLOR_MAP.dark.long[0]);
|
|
71
|
+
expect(style).toContain(COLOR_MAP.dark.long[1]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('uses light mode short colors when isDark is false', () => {
|
|
75
|
+
const { getByTestId } = render(
|
|
76
|
+
<LegendBar
|
|
77
|
+
isDark={false}
|
|
78
|
+
label="short"
|
|
79
|
+
type="short"
|
|
80
|
+
values={mockValues}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
const segment = getByTestId('legend-bar-segment');
|
|
84
|
+
const style = segment.getAttribute('style');
|
|
85
|
+
expect(style).toContain(COLOR_MAP.light.short[0]);
|
|
86
|
+
expect(style).toContain(COLOR_MAP.light.short[1]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('uses dark mode short colors when isDark is true', () => {
|
|
90
|
+
const { getByTestId } = render(
|
|
91
|
+
<LegendBar
|
|
92
|
+
isDark={true}
|
|
93
|
+
label="short"
|
|
94
|
+
type="short"
|
|
95
|
+
values={mockValues}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
const segment = getByTestId('legend-bar-segment');
|
|
99
|
+
const style = segment.getAttribute('style');
|
|
100
|
+
expect(style).toContain(COLOR_MAP.dark.short[0]);
|
|
101
|
+
expect(style).toContain(COLOR_MAP.dark.short[1]);
|
|
102
|
+
});
|
|
32
103
|
});
|
|
33
104
|
});
|
|
34
105
|
});
|