@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.
Files changed (49) hide show
  1. package/CHANGELOG.md +396 -0
  2. package/dist/main/CrowdViewWidget/Main.js +4 -2
  3. package/dist/main/CrowdViewWidget/Main.js.map +1 -1
  4. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +8 -3
  5. package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
  6. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
  7. package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  8. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
  9. package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
  10. package/dist/main/CrowdViewWidget/components/Legend/Legend.js +4 -1
  11. package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  12. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
  13. package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  14. package/dist/main/CrowdViewWidget/constants.js +9 -2
  15. package/dist/main/CrowdViewWidget/constants.js.map +1 -1
  16. package/dist/main/CrowdViewWidget/selectConfig.js +6 -6
  17. package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
  18. package/dist/module/CrowdViewWidget/Main.js +4 -2
  19. package/dist/module/CrowdViewWidget/Main.js.map +1 -1
  20. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +9 -4
  21. package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
  22. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
  23. package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
  24. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
  25. package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
  26. package/dist/module/CrowdViewWidget/components/Legend/Legend.js +4 -1
  27. package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
  28. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
  29. package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
  30. package/dist/module/CrowdViewWidget/constants.js +9 -2
  31. package/dist/module/CrowdViewWidget/constants.js.map +1 -1
  32. package/dist/module/CrowdViewWidget/selectConfig.js +6 -6
  33. package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
  34. package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +1 -1
  35. package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +2 -1
  36. package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +2 -1
  37. package/dist/types/CrowdViewWidget/constants.d.ts +8 -2
  38. package/package.json +3 -3
  39. package/src/CrowdViewWidget/Main.tsx +2 -2
  40. package/src/CrowdViewWidget/components/Chart/chartOptions.ts +15 -3
  41. package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +6 -2
  42. package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +11 -4
  43. package/src/CrowdViewWidget/components/Legend/Legend.tsx +4 -0
  44. package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +4 -2
  45. package/src/CrowdViewWidget/constants.ts +10 -2
  46. package/src/CrowdViewWidget/selectConfig.ts +8 -8
  47. package/test/components/Chart/utils/chartUtils.test.ts +23 -6
  48. package/test/components/Legend.test.tsx +44 -0
  49. 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 label="long" type="long" values={mockValues} />
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 label="short" type="short" values={mockValues} />
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
  });