@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.
- package/CHANGELOG.md +456 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +7 -7
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/Main.js +10 -10
- package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +11 -11
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +9 -9
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/constants.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/render.js +8 -8
- package/dist/main/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/main/gql/types/fragment-masking.js.map +1 -1
- package/dist/main/gql/types/gql.js +1 -1
- package/dist/main/gql/types/gql.js.map +1 -1
- package/dist/main/gql/types/graphql.js +64 -64
- package/dist/main/gql/types/graphql.js.map +1 -1
- package/dist/main/gql/types/index.js.map +1 -1
- package/dist/main/translations/index.js +1 -1
- package/dist/main/translations/index.js.map +1 -1
- package/dist/main/translations/translations.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +7 -7
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +9 -9
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/Main.js +10 -10
- package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +10 -10
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/formatters.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js +2 -2
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/options/utils.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js +4 -4
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +10 -10
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/config.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/constants.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/render.js +8 -8
- package/dist/module/CurrencyPowerBalanceWidget/render.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/types.js.map +1 -1
- package/dist/module/gql/types/fragment-masking.js.map +1 -1
- package/dist/module/gql/types/gql.js +1 -1
- package/dist/module/gql/types/gql.js.map +1 -1
- package/dist/module/gql/types/graphql.js +64 -64
- package/dist/module/gql/types/graphql.js.map +1 -1
- package/dist/module/gql/types/index.js +2 -2
- package/dist/module/gql/types/index.js.map +1 -1
- package/dist/module/translations/index.js +1 -1
- package/dist/module/translations/index.js.map +1 -1
- package/dist/module/translations/translations.js.map +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/ChartWithData.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/CurrencyPowerBalance.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/Main.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/Chart.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/constants.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/formatters.d.ts +4 -3
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/getOption.d.ts +2 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/options/utils.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/Chart/types.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.d.ts +1 -1
- package/dist/types/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.d.ts +3 -3
- package/dist/types/CurrencyPowerBalanceWidget/types.d.ts +2 -2
- package/dist/types/gql/types/gql.d.ts +2 -2
- package/dist/types/gql/types/index.d.ts +2 -2
- package/dist/types/translations/index.d.ts +2 -2
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +31 -17
- package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +16 -9
- package/src/CurrencyPowerBalanceWidget/Main.tsx +18 -9
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +25 -20
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/constants.ts +11 -10
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/formatters.ts +42 -22
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getOption.ts +59 -44
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/getResponsiveOption.ts +7 -4
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/types.ts +1 -1
- package/src/CurrencyPowerBalanceWidget/components/Chart/options/utils.ts +10 -9
- package/src/CurrencyPowerBalanceWidget/components/Chart/types.ts +4 -1
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSelect.tsx +21 -15
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +47 -37
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/types.ts +3 -3
- package/src/CurrencyPowerBalanceWidget/config.ts +8 -2
- package/src/CurrencyPowerBalanceWidget/constants.ts +2 -1
- package/src/CurrencyPowerBalanceWidget/render.tsx +24 -20
- package/src/CurrencyPowerBalanceWidget/types.ts +5 -3
- package/src/gql/types/fragment-masking.ts +41 -21
- package/src/gql/types/gql.ts +7 -3
- package/src/gql/types/graphql.ts +117 -44
- package/src/gql/types/index.ts +2 -2
- package/src/translations/index.ts +4 -4
- package/src/translations/translations.ts +2 -1
- package/test/Main.test.tsx +28 -14
- package/test/chartFormatters.test.ts +84 -24
- package/test/responsesMocks.ts +254 -255
- package/test/utils.test.ts +0 -1
package/test/Main.test.tsx
CHANGED
|
@@ -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(
|
|
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
|
|
33
|
+
<Main
|
|
34
|
+
currencies={['USD', 'EUR']}
|
|
35
|
+
timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay}
|
|
36
|
+
/>
|
|
31
37
|
</MockLayoutProvider>
|
|
32
|
-
</MockedProvider
|
|
38
|
+
</MockedProvider>
|
|
33
39
|
);
|
|
34
40
|
|
|
35
|
-
expect(
|
|
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(
|
|
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(
|
|
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(
|
|
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,
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
expect(element.querySelectorAll('span')[
|
|
38
|
-
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
123
|
+
expect(
|
|
124
|
+
xAxisLabelFormatter(
|
|
125
|
+
'2024-01-05T05:45:00Z',
|
|
126
|
+
CurrencyPowerBalanceTimeUnit.H4
|
|
127
|
+
)
|
|
128
|
+
).toEqual('05:45');
|
|
69
129
|
});
|
|
70
130
|
});
|