@oanda/labs-live-rates-table-widget 1.0.38 → 1.0.40

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