@oanda/labs-live-rates-table-widget 1.0.49 → 1.0.50

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 (108) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/dist/main/LiveRatesTableWidget/Main.js +26 -33
  3. package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
  4. package/dist/main/LiveRatesTableWidget/config.js +12 -7
  5. package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
  6. package/dist/main/LiveRatesTableWidget/constant.js +2 -2
  7. package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
  8. package/dist/main/LiveRatesTableWidget/types.js +0 -10
  9. package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
  10. package/dist/main/LiveRatesTableWidget/utils.js +8 -49
  11. package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
  12. package/dist/module/LiveRatesTableWidget/Main.js +28 -35
  13. package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
  14. package/dist/module/LiveRatesTableWidget/config.js +13 -9
  15. package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
  16. package/dist/module/LiveRatesTableWidget/constant.js +2 -2
  17. package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
  18. package/dist/module/LiveRatesTableWidget/types.js +0 -9
  19. package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
  20. package/dist/module/LiveRatesTableWidget/utils.js +8 -47
  21. package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
  22. package/dist/types/LiveRatesTableWidget/config.d.ts +9 -28
  23. package/dist/types/LiveRatesTableWidget/constant.d.ts +2 -2
  24. package/dist/types/LiveRatesTableWidget/types.d.ts +6 -47
  25. package/dist/types/LiveRatesTableWidget/utils.d.ts +4 -15
  26. package/package.json +3 -3
  27. package/src/LiveRatesTableWidget/Main.tsx +44 -51
  28. package/src/LiveRatesTableWidget/config.ts +27 -10
  29. package/src/LiveRatesTableWidget/constant.ts +6 -6
  30. package/src/LiveRatesTableWidget/types.tsx +11 -53
  31. package/src/LiveRatesTableWidget/utils.ts +21 -65
  32. package/test/mocks.ts +1 -16
  33. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -96
  34. package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
  35. package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js +0 -17
  36. package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
  37. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +0 -37
  38. package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
  39. package/dist/main/LiveRatesTableWidget/components/Cards/index.js +0 -17
  40. package/dist/main/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
  41. package/dist/main/LiveRatesTableWidget/components/Cards/types.js +0 -6
  42. package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
  43. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -46
  44. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
  45. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -17
  46. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
  47. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -6
  48. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
  49. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -20
  50. package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
  51. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -104
  52. package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
  53. package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js +0 -17
  54. package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
  55. package/dist/main/LiveRatesTableWidget/components/index.js +0 -50
  56. package/dist/main/LiveRatesTableWidget/components/index.js.map +0 -1
  57. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -89
  58. package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
  59. package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js +0 -2
  60. package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
  61. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +0 -30
  62. package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
  63. package/dist/module/LiveRatesTableWidget/components/Cards/index.js +0 -2
  64. package/dist/module/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
  65. package/dist/module/LiveRatesTableWidget/components/Cards/types.js +0 -2
  66. package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
  67. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -39
  68. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
  69. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -2
  70. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
  71. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -2
  72. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
  73. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -13
  74. package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
  75. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -97
  76. package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
  77. package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js +0 -2
  78. package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
  79. package/dist/module/LiveRatesTableWidget/components/index.js +0 -5
  80. package/dist/module/LiveRatesTableWidget/components/index.js.map +0 -1
  81. package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +0 -4
  82. package/dist/types/LiveRatesTableWidget/components/CardWithData/index.d.ts +0 -1
  83. package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +0 -4
  84. package/dist/types/LiveRatesTableWidget/components/Cards/index.d.ts +0 -1
  85. package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +0 -12
  86. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
  87. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/index.d.ts +0 -1
  88. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +0 -11
  89. package/dist/types/LiveRatesTableWidget/components/LineChartWithData/utils.d.ts +0 -1
  90. package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +0 -4
  91. package/dist/types/LiveRatesTableWidget/components/RowWithData/index.d.ts +0 -1
  92. package/dist/types/LiveRatesTableWidget/components/index.d.ts +0 -4
  93. package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +0 -133
  94. package/src/LiveRatesTableWidget/components/CardWithData/index.ts +0 -1
  95. package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +0 -44
  96. package/src/LiveRatesTableWidget/components/Cards/index.ts +0 -1
  97. package/src/LiveRatesTableWidget/components/Cards/types.tsx +0 -13
  98. package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +0 -53
  99. package/src/LiveRatesTableWidget/components/LineChartWithData/index.ts +0 -1
  100. package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +0 -13
  101. package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +0 -14
  102. package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +0 -150
  103. package/src/LiveRatesTableWidget/components/RowWithData/index.ts +0 -1
  104. package/src/LiveRatesTableWidget/components/index.ts +0 -4
  105. package/test/CardWithData.test.tsx +0 -74
  106. package/test/Cards.test.tsx +0 -130
  107. package/test/LineChartWithData.test.tsx +0 -263
  108. package/test/RowWithData.test.tsx +0 -81
@@ -1,263 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import { MockedProvider } from '@apollo/client/testing';
5
- import { render } from '@testing-library/react';
6
- import React from 'react';
7
-
8
- import { getInstrumentsChart } from '../src/gql/getInstrumentsChart';
9
- import { Division } from '../src/gql/types/graphql';
10
- import { LineChartWithData } from '../src/LiveRatesTableWidget/components/LineChartWithData';
11
-
12
- const chartPointsMocks = [
13
- {
14
- request: {
15
- query: getInstrumentsChart,
16
- variables: {
17
- instruments: ['EUR_USD'],
18
- division: 'OC',
19
- },
20
- },
21
- result: {
22
- data: {
23
- topicalInstrumentsCharts: [
24
- {
25
- name: 'EUR_USD',
26
- displayName: 'EUR_USD',
27
- chart: [
28
- 1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
29
- 1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
30
- 1.05556,
31
- ],
32
- },
33
- ],
34
- },
35
- },
36
- },
37
- ];
38
-
39
- const chartsPointsBelowTenMocks = [
40
- {
41
- request: {
42
- query: getInstrumentsChart,
43
- variables: {
44
- instruments: ['CAD_JPY'],
45
- division: 'OC',
46
- },
47
- },
48
- result: {
49
- data: {
50
- topicalInstrumentsCharts: [
51
- {
52
- name: 'CAD_JPY',
53
- displayName: 'CAD_JPY',
54
- chart: [0.8601, 0.85996, 0.85962, 0.86022, 0.8592],
55
- },
56
- ],
57
- },
58
- },
59
- },
60
- ];
61
-
62
- describe('LineChartWithData component', () => {
63
- const record = {
64
- instrument: 'EUR_USD',
65
- displayName: 'EUR_USD',
66
- buy: 1.04508,
67
- sell: 1.04523,
68
- spread: 1.2,
69
- dailyPercentChange: '+3,23%',
70
- };
71
-
72
- it('should render line chart', async () => {
73
- const { findByTestId } = render(
74
- <MockedProvider mocks={chartPointsMocks}>
75
- <LineChartWithData
76
- division={Division.Oc}
77
- isLoading={false}
78
- record={record}
79
- />
80
- </MockedProvider>
81
- );
82
-
83
- expect(await findByTestId('line-chart')).toBeInTheDocument();
84
- });
85
- it('should render line chart in green when daily price change is above 0%', async () => {
86
- const { findByTestId, container } = render(
87
- <MockedProvider mocks={chartPointsMocks}>
88
- <LineChartWithData
89
- division={Division.Oc}
90
- isLoading={false}
91
- record={record}
92
- />
93
- </MockedProvider>
94
- );
95
-
96
- expect(await findByTestId('line-chart')).toBeInTheDocument();
97
-
98
- expect(container.querySelector('path')).toHaveAttribute(
99
- 'stroke',
100
- '#00D37E'
101
- );
102
- });
103
- it('should render line chart in red when daily price change is below 0%', async () => {
104
- record.dailyPercentChange = '-1.56%';
105
-
106
- const { findByTestId, container } = render(
107
- <MockedProvider mocks={chartPointsMocks}>
108
- <LineChartWithData
109
- division={Division.Oc}
110
- isLoading={false}
111
- record={record}
112
- />
113
- </MockedProvider>
114
- );
115
-
116
- expect(await findByTestId('line-chart')).toBeInTheDocument();
117
-
118
- expect(container.querySelector('path')).toHaveAttribute(
119
- 'stroke',
120
- '#FE005B'
121
- );
122
- });
123
- it('should render line chart in grey when daily price change equals 0%', async () => {
124
- record.dailyPercentChange = '0%';
125
-
126
- const { findByTestId, container } = render(
127
- <MockedProvider mocks={chartPointsMocks}>
128
- <LineChartWithData
129
- division={Division.Oc}
130
- isLoading={false}
131
- record={record}
132
- />
133
- </MockedProvider>
134
- );
135
-
136
- expect(await findByTestId('line-chart')).toBeInTheDocument();
137
-
138
- expect(container.querySelector('path')).toHaveAttribute(
139
- 'stroke',
140
- '#9EA4AC'
141
- );
142
- });
143
- it('should render line chart in grey when daily price change equals undefined', async () => {
144
- record.dailyPercentChange = 'undefined';
145
-
146
- const { findByTestId, container } = render(
147
- <MockedProvider mocks={chartPointsMocks}>
148
- <LineChartWithData
149
- division={Division.Oc}
150
- isLoading={false}
151
- record={record}
152
- />
153
- </MockedProvider>
154
- );
155
-
156
- expect(await findByTestId('line-chart')).toBeInTheDocument();
157
-
158
- expect(container.querySelector('path')).toHaveAttribute(
159
- 'stroke',
160
- '#9EA4AC'
161
- );
162
- });
163
- it('should render line chart in green when daily price change is above 0%, dark mode', async () => {
164
- record.dailyPercentChange = '+3,23%';
165
-
166
- const { findByTestId, container } = render(
167
- <MockedProvider mocks={chartPointsMocks}>
168
- <LineChartWithData
169
- isDarkMode
170
- division={Division.Oc}
171
- isLoading={false}
172
- record={record}
173
- />
174
- </MockedProvider>
175
- );
176
-
177
- expect(await findByTestId('line-chart')).toBeInTheDocument();
178
-
179
- expect(container.querySelector('path')).toHaveAttribute(
180
- 'stroke',
181
- '#008573'
182
- );
183
- });
184
- it('should render line chart in red when daily price change is below 0%, dark mode', async () => {
185
- record.dailyPercentChange = '-1.56%';
186
-
187
- const { findByTestId, container } = render(
188
- <MockedProvider mocks={chartPointsMocks}>
189
- <LineChartWithData
190
- isDarkMode
191
- division={Division.Oc}
192
- isLoading={false}
193
- record={record}
194
- />
195
- </MockedProvider>
196
- );
197
-
198
- expect(await findByTestId('line-chart')).toBeInTheDocument();
199
-
200
- expect(container.querySelector('path')).toHaveAttribute(
201
- 'stroke',
202
- '#DA6325'
203
- );
204
- });
205
- it('should render line chart in grey when daily price change equals 0%, dark mode', async () => {
206
- record.dailyPercentChange = '0%';
207
-
208
- const { findByTestId, container } = render(
209
- <MockedProvider mocks={chartPointsMocks}>
210
- <LineChartWithData
211
- isDarkMode
212
- division={Division.Oc}
213
- isLoading={false}
214
- record={record}
215
- />
216
- </MockedProvider>
217
- );
218
-
219
- expect(await findByTestId('line-chart')).toBeInTheDocument();
220
-
221
- expect(container.querySelector('path')).toHaveAttribute(
222
- 'stroke',
223
- '#9EA4AC'
224
- );
225
- });
226
- it('should render line chart in grey when daily price change equals undefined, dark mode', async () => {
227
- record.dailyPercentChange = 'undefined';
228
-
229
- const { findByTestId, container } = render(
230
- <MockedProvider mocks={chartPointsMocks}>
231
- <LineChartWithData
232
- isDarkMode
233
- division={Division.Oc}
234
- isLoading={false}
235
- record={record}
236
- />
237
- </MockedProvider>
238
- );
239
-
240
- expect(await findByTestId('line-chart')).toBeInTheDocument();
241
-
242
- expect(container.querySelector('path')).toHaveAttribute(
243
- 'stroke',
244
- '#9EA4AC'
245
- );
246
- });
247
- it('should render empty value when number of points is below 10', async () => {
248
- record.instrument = 'CAD_JPY';
249
-
250
- const { queryByTestId, findByTestId } = render(
251
- <MockedProvider mocks={chartsPointsBelowTenMocks}>
252
- <LineChartWithData
253
- division={Division.Oc}
254
- isLoading={false}
255
- record={record}
256
- />
257
- </MockedProvider>
258
- );
259
-
260
- expect(queryByTestId('line-chart')).not.toBeInTheDocument();
261
- expect(await findByTestId('line-chart-empty-value')).toBeInTheDocument();
262
- });
263
- });
@@ -1,81 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import { MockedProvider } from '@apollo/client/testing';
5
- import { MockLayoutProvider } from '@oanda/labs-widget-common';
6
- import { render } from '@testing-library/react';
7
- import React from 'react';
8
-
9
- import { getInstrumentsChart } from '../src/gql/getInstrumentsChart';
10
- import { Division } from '../src/gql/types/graphql';
11
- import { RowWithData } from '../src/LiveRatesTableWidget/components/RowWithData';
12
- import { ColumnsNames } from '../src/LiveRatesTableWidget/types';
13
-
14
- const chartPointsMocks = [
15
- {
16
- request: {
17
- query: getInstrumentsChart,
18
- variables: {
19
- instruments: ['EUR_USD'],
20
- division: 'OC',
21
- },
22
- },
23
- result: {
24
- data: {
25
- topicalInstrumentsCharts: [
26
- {
27
- name: 'EUR_USD',
28
- displayName: 'EUR_USD',
29
- chart: [
30
- 1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
31
- 1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
32
- 1.05556,
33
- ],
34
- },
35
- ],
36
- },
37
- },
38
- },
39
- ];
40
-
41
- describe('RowWithData component', () => {
42
- const record = {
43
- instrument: 'EUR_USD',
44
- displayName: 'EUR_USD',
45
- buy: 1.04508,
46
- sell: 1.04523,
47
- spread: 1.2,
48
- dailyPercentChange: '+3,23%',
49
- };
50
- const columns = [
51
- ColumnsNames.SELL,
52
- ColumnsNames.BUY,
53
- ColumnsNames.DAILY_CHANGE,
54
- ColumnsNames.CHART,
55
- ColumnsNames.SPREAD,
56
- ];
57
- it('should render table row', async () => {
58
- const { getByTestId, getAllByTestId, findByTestId } = render(
59
- <MockedProvider mocks={chartPointsMocks}>
60
- <MockLayoutProvider>
61
- <table>
62
- <tbody>
63
- <RowWithData
64
- hasBackgroundColor
65
- activeColumns={columns}
66
- division={Division.Oc}
67
- loading={false}
68
- record={record}
69
- target={null}
70
- />
71
- </tbody>
72
- </table>
73
- </MockLayoutProvider>
74
- </MockedProvider>
75
- );
76
-
77
- expect(getByTestId('table-row')).toBeInTheDocument();
78
- expect(await findByTestId('line-chart')).toBeInTheDocument();
79
- expect(getAllByTestId('table-cell').length).toEqual(5);
80
- });
81
- });