@oanda/labs-currency-power-balance-widget 1.0.112 → 1.0.113

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 (119) hide show
  1. package/CHANGELOG.md +456 -0
  2. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +7 -7
  3. package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  4. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
  5. package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  6. package/dist/main/CurrencyPowerBalanceWidget/Main.js +10 -10
  7. package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  8. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +11 -11
  9. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  10. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  11. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  12. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +1 -1
  13. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  14. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  15. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
  16. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
  17. package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  18. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
  19. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  20. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +9 -9
  21. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  22. package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  23. package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
  24. package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -1
  25. package/dist/main/CurrencyPowerBalanceWidget/render.js +8 -8
  26. package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
  27. package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
  28. package/dist/main/gql/types/fragment-masking.js.map +1 -1
  29. package/dist/main/gql/types/gql.js +1 -1
  30. package/dist/main/gql/types/gql.js.map +1 -1
  31. package/dist/main/gql/types/graphql.js +64 -64
  32. package/dist/main/gql/types/graphql.js.map +1 -1
  33. package/dist/main/gql/types/index.js.map +1 -1
  34. package/dist/main/translations/index.js +1 -1
  35. package/dist/main/translations/index.js.map +1 -1
  36. package/dist/main/translations/translations.js.map +1 -1
  37. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +7 -7
  38. package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
  39. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
  40. package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
  41. package/dist/module/CurrencyPowerBalanceWidget/Main.js +10 -10
  42. package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
  43. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +10 -10
  44. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
  45. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +1 -1
  46. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
  47. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
  48. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
  49. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -2
  50. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
  51. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
  52. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
  53. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
  54. package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
  55. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
  56. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
  57. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +10 -10
  58. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
  59. package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
  60. package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
  61. package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -1
  62. package/dist/module/CurrencyPowerBalanceWidget/render.js +8 -8
  63. package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
  64. package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
  65. package/dist/module/gql/types/fragment-masking.js.map +1 -1
  66. package/dist/module/gql/types/gql.js +1 -1
  67. package/dist/module/gql/types/gql.js.map +1 -1
  68. package/dist/module/gql/types/graphql.js +64 -64
  69. package/dist/module/gql/types/graphql.js.map +1 -1
  70. package/dist/module/gql/types/index.js +2 -2
  71. package/dist/module/gql/types/index.js.map +1 -1
  72. package/dist/module/translations/index.js +1 -1
  73. package/dist/module/translations/index.js.map +1 -1
  74. package/dist/module/translations/translations.js.map +1 -1
  75. package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
  76. package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
  77. package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +1 -1
  78. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
  79. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +1 -1
  80. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +4 -3
  81. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -1
  82. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +1 -1
  83. package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -1
  84. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
  85. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +1 -1
  86. package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +3 -3
  87. package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +2 -2
  88. package/dist/types/gql/types/gql.d.ts +2 -2
  89. package/dist/types/gql/types/index.d.ts +2 -2
  90. package/dist/types/translations/index.d.ts +2 -2
  91. package/package.json +3 -3
  92. package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +31 -17
  93. package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +16 -9
  94. package/src/CurrencyPowerBalanceWidget/Main.tsx +18 -9
  95. package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +25 -20
  96. package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts +11 -10
  97. package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +42 -22
  98. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +59 -44
  99. package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +7 -4
  100. package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +1 -1
  101. package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +10 -9
  102. package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +4 -1
  103. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +21 -15
  104. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +47 -37
  105. package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +3 -3
  106. package/src/CurrencyPowerBalanceWidget/config.ts +8 -2
  107. package/src/CurrencyPowerBalanceWidget/constants.ts +2 -1
  108. package/src/CurrencyPowerBalanceWidget/render.tsx +24 -20
  109. package/src/CurrencyPowerBalanceWidget/types.ts +5 -3
  110. package/src/gql/types/fragment-masking.ts +41 -21
  111. package/src/gql/types/gql.ts +7 -3
  112. package/src/gql/types/graphql.ts +117 -44
  113. package/src/gql/types/index.ts +2 -2
  114. package/src/translations/index.ts +4 -4
  115. package/src/translations/translations.ts +2 -1
  116. package/test/Main.test.tsx +28 -14
  117. package/test/chartFormatters.test.ts +84 -24
  118. package/test/responsesMocks.ts +254 -255
  119. package/test/utils.test.ts +0 -1
@@ -1,13 +1,14 @@
1
1
  /**
2
2
  * @jest-environment jsdom
3
3
  */
4
- import React from 'react';
5
- import { render } from '@testing-library/react';
6
4
  import { MockedProvider } from '@apollo/client/testing';
7
5
  import { MockLayoutProvider, Size } from '@oanda/labs-widget-common';
6
+ import { render } from '@testing-library/react';
7
+ import React from 'react';
8
+
8
9
  import { Main } from '../src/CurrencyPowerBalanceWidget/Main';
9
- import { mockResponse } from './responsesMocks';
10
10
  import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
11
+ import { mockResponse } from './responsesMocks';
11
12
 
12
13
  describe('Main component', () => {
13
14
  it('should render tool desktop view', async () => {
@@ -16,10 +17,12 @@ describe('Main component', () => {
16
17
  <MockLayoutProvider>
17
18
  <Main />
18
19
  </MockLayoutProvider>
19
- </MockedProvider>,
20
+ </MockedProvider>
20
21
  );
21
22
 
22
- expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
23
+ expect(
24
+ await findByTestId('currency-power-balance-wrapper')
25
+ ).toBeInTheDocument();
23
26
  expect(getByTestId('time-unit-switch')).toBeInTheDocument();
24
27
  expect(queryByTestId('time-unit-label')).not.toBeInTheDocument();
25
28
  });
@@ -27,12 +30,17 @@ describe('Main component', () => {
27
30
  const { findByTestId, getByTestId, queryByTestId } = render(
28
31
  <MockedProvider mocks={mockResponse}>
29
32
  <MockLayoutProvider>
30
- <Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} currencies={['USD', 'EUR']} />
33
+ <Main
34
+ currencies={['USD', 'EUR']}
35
+ timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay}
36
+ />
31
37
  </MockLayoutProvider>
32
- </MockedProvider>,
38
+ </MockedProvider>
33
39
  );
34
40
 
35
- expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
41
+ expect(
42
+ await findByTestId('currency-power-balance-wrapper')
43
+ ).toBeInTheDocument();
36
44
  expect(getByTestId('time-unit-label')).toBeInTheDocument();
37
45
  expect(queryByTestId('time-unit-switch')).not.toBeInTheDocument();
38
46
  });
@@ -42,10 +50,12 @@ describe('Main component', () => {
42
50
  <MockLayoutProvider>
43
51
  <Main currencies={['USD', 'EUR']} />
44
52
  </MockLayoutProvider>
45
- </MockedProvider>,
53
+ </MockedProvider>
46
54
  );
47
55
 
48
- expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
56
+ expect(
57
+ await findByTestId('currency-power-balance-wrapper')
58
+ ).toBeInTheDocument();
49
59
  expect(getByTestId('time-unit-switch')).toBeInTheDocument();
50
60
  expect(queryByTestId('time-unit-label')).not.toBeInTheDocument();
51
61
  });
@@ -55,10 +65,12 @@ describe('Main component', () => {
55
65
  <MockLayoutProvider>
56
66
  <Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} />
57
67
  </MockLayoutProvider>
58
- </MockedProvider>,
68
+ </MockedProvider>
59
69
  );
60
70
 
61
- expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
71
+ expect(
72
+ await findByTestId('currency-power-balance-wrapper')
73
+ ).toBeInTheDocument();
62
74
  expect(getByTestId('time-unit-switch')).toBeInTheDocument();
63
75
  expect(queryByTestId('time-unit-label')).not.toBeInTheDocument();
64
76
  });
@@ -68,10 +80,12 @@ describe('Main component', () => {
68
80
  <MockLayoutProvider size={Size.MOBILE}>
69
81
  <Main />
70
82
  </MockLayoutProvider>
71
- </MockedProvider>,
83
+ </MockedProvider>
72
84
  );
73
85
 
74
- expect(await findByTestId('currency-power-balance-wrapper')).toBeInTheDocument();
86
+ expect(
87
+ await findByTestId('currency-power-balance-wrapper')
88
+ ).toBeInTheDocument();
75
89
  expect(getByTestId('time-unit-select')).toBeInTheDocument();
76
90
  expect(queryByTestId('time-unit-label')).not.toBeInTheDocument();
77
91
  });
@@ -3,7 +3,9 @@
3
3
  */
4
4
 
5
5
  import {
6
- intervalFormatter, xAxisLabelFormatter, tooltipFormatter,
6
+ intervalFormatter,
7
+ tooltipFormatter,
8
+ xAxisLabelFormatter,
7
9
  } from '../src/CurrencyPowerBalanceWidget/components/Chart/options/formatters';
8
10
  import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
9
11
 
@@ -18,53 +20,111 @@ describe('intervalFormatter', () => {
18
20
 
19
21
  describe('tooltipFormatter', () => {
20
22
  it('should sort & format tooltip content', () => {
21
- const values = [{
22
- marker: '<span>Marker 1</span>',
23
- seriesName: 'Name 1',
24
- value: ['2023-10-27T14:00:00Z', '-30.91'],
25
- }, {
26
- marker: '<span>Marker 2</span>',
27
- seriesName: 'Name 2',
28
- value: ['2023-10-27T14:00:00Z', '-20.23'],
29
- }];
23
+ const values = [
24
+ {
25
+ marker: '<span>Marker 1</span>',
26
+ seriesName: 'Name 1',
27
+ value: ['2023-10-27T14:00:00Z', '-30.91'],
28
+ },
29
+ {
30
+ marker: '<span>Marker 2</span>',
31
+ seriesName: 'Name 2',
32
+ value: ['2023-10-27T14:00:00Z', '-20.23'],
33
+ },
34
+ ];
30
35
 
31
36
  const element = document.createElement('div');
32
37
  element.innerHTML = tooltipFormatter(values);
33
38
 
34
- expect(element.querySelector('span')).toContainHTML('<span style="margin-bottom:5px;">10/27/2023, 14:00 UTC</span>');
35
- expect(element.querySelectorAll('span')[1]).toContainHTML('<span>Marker 2</span>');
36
- expect(element.querySelectorAll('span')[3]).toContainHTML('<span>-20.23</span>');
37
- expect(element.querySelectorAll('span')[4]).toContainHTML('<span>Marker 1</span>');
38
- expect(element.querySelectorAll('span')[6]).toContainHTML('<span>-30.91</span>');
39
+ expect(element.querySelector('span')).toContainHTML(
40
+ '<span style="margin-bottom:5px;">10/27/2023, 14:00 UTC</span>'
41
+ );
42
+ expect(element.querySelectorAll('span')[1]).toContainHTML(
43
+ '<span>Marker 2</span>'
44
+ );
45
+ expect(element.querySelectorAll('span')[3]).toContainHTML(
46
+ '<span>-20.23</span>'
47
+ );
48
+ expect(element.querySelectorAll('span')[4]).toContainHTML(
49
+ '<span>Marker 1</span>'
50
+ );
51
+ expect(element.querySelectorAll('span')[6]).toContainHTML(
52
+ '<span>-30.91</span>'
53
+ );
39
54
  });
40
55
  });
41
56
 
42
57
  describe('xAxisLabelFormatter', () => {
43
58
  it('should format x axis label to date for 1 week time unit', () => {
44
- expect(xAxisLabelFormatter('2023-10-22T10:00:00Z', CurrencyPowerBalanceTimeUnit.W1)).toEqual('10/22');
59
+ expect(
60
+ xAxisLabelFormatter(
61
+ '2023-10-22T10:00:00Z',
62
+ CurrencyPowerBalanceTimeUnit.W1
63
+ )
64
+ ).toEqual('10/22');
45
65
  });
46
66
  it('should format x axis label to date for 1 month time unit', () => {
47
- expect(xAxisLabelFormatter('2023-10-20T10:00:00Z', CurrencyPowerBalanceTimeUnit.M1)).toEqual('10/20');
67
+ expect(
68
+ xAxisLabelFormatter(
69
+ '2023-10-20T10:00:00Z',
70
+ CurrencyPowerBalanceTimeUnit.M1
71
+ )
72
+ ).toEqual('10/20');
48
73
  });
49
74
  it('should format x axis label to date for 3 months time unit', () => {
50
- expect(xAxisLabelFormatter('2023-10-10T10:00:00Z', CurrencyPowerBalanceTimeUnit.M3)).toEqual('10/10');
75
+ expect(
76
+ xAxisLabelFormatter(
77
+ '2023-10-10T10:00:00Z',
78
+ CurrencyPowerBalanceTimeUnit.M3
79
+ )
80
+ ).toEqual('10/10');
51
81
  });
52
82
  it('should format x axis label to date for midnight', () => {
53
- expect(xAxisLabelFormatter('2023-09-20T00:00:00Z', CurrencyPowerBalanceTimeUnit.CurrentDay)).toEqual('9/20');
83
+ expect(
84
+ xAxisLabelFormatter(
85
+ '2023-09-20T00:00:00Z',
86
+ CurrencyPowerBalanceTimeUnit.CurrentDay
87
+ )
88
+ ).toEqual('9/20');
54
89
  });
55
90
  it('should format x axis label to time for current day', () => {
56
- expect(xAxisLabelFormatter('2023-09-20T01:00:00Z', CurrencyPowerBalanceTimeUnit.CurrentDay)).toEqual('01:00');
91
+ expect(
92
+ xAxisLabelFormatter(
93
+ '2023-09-20T01:00:00Z',
94
+ CurrencyPowerBalanceTimeUnit.CurrentDay
95
+ )
96
+ ).toEqual('01:00');
57
97
  });
58
98
  it('should format x axis label to time for previous day', () => {
59
- expect(xAxisLabelFormatter('2023-12-18T05:00:00Z', CurrencyPowerBalanceTimeUnit.PreviousDay)).toEqual('05:00');
99
+ expect(
100
+ xAxisLabelFormatter(
101
+ '2023-12-18T05:00:00Z',
102
+ CurrencyPowerBalanceTimeUnit.PreviousDay
103
+ )
104
+ ).toEqual('05:00');
60
105
  });
61
106
  it('should format x axis label to time for 24 hours', () => {
62
- expect(xAxisLabelFormatter('2023-06-01T12:20:00Z', CurrencyPowerBalanceTimeUnit.H24)).toEqual('12:20');
107
+ expect(
108
+ xAxisLabelFormatter(
109
+ '2023-06-01T12:20:00Z',
110
+ CurrencyPowerBalanceTimeUnit.H24
111
+ )
112
+ ).toEqual('12:20');
63
113
  });
64
114
  it('should format x axis label to time for 8 hours', () => {
65
- expect(xAxisLabelFormatter('2023-08-23T14:00:00Z', CurrencyPowerBalanceTimeUnit.H8)).toEqual('14:00');
115
+ expect(
116
+ xAxisLabelFormatter(
117
+ '2023-08-23T14:00:00Z',
118
+ CurrencyPowerBalanceTimeUnit.H8
119
+ )
120
+ ).toEqual('14:00');
66
121
  });
67
122
  it('should format x axis label to time for 4 hours', () => {
68
- expect(xAxisLabelFormatter('2024-01-05T05:45:00Z', CurrencyPowerBalanceTimeUnit.H4)).toEqual('05:45');
123
+ expect(
124
+ xAxisLabelFormatter(
125
+ '2024-01-05T05:45:00Z',
126
+ CurrencyPowerBalanceTimeUnit.H4
127
+ )
128
+ ).toEqual('05:45');
69
129
  });
70
130
  });