@oanda/labs-live-rates-table-widget 1.0.49 → 1.0.51
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 +412 -0
- package/dist/main/LiveRatesTableWidget/Main.js +26 -33
- package/dist/main/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/config.js +12 -7
- package/dist/main/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/constant.js +2 -2
- package/dist/main/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/types.js +0 -10
- package/dist/main/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/main/LiveRatesTableWidget/utils.js +8 -49
- package/dist/main/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/Main.js +28 -35
- package/dist/module/LiveRatesTableWidget/Main.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/config.js +13 -9
- package/dist/module/LiveRatesTableWidget/config.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/constant.js +2 -2
- package/dist/module/LiveRatesTableWidget/constant.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/types.js +0 -9
- package/dist/module/LiveRatesTableWidget/types.js.map +1 -1
- package/dist/module/LiveRatesTableWidget/utils.js +8 -47
- package/dist/module/LiveRatesTableWidget/utils.js.map +1 -1
- package/dist/types/LiveRatesTableWidget/config.d.ts +9 -28
- package/dist/types/LiveRatesTableWidget/constant.d.ts +2 -2
- package/dist/types/LiveRatesTableWidget/types.d.ts +6 -47
- package/dist/types/LiveRatesTableWidget/utils.d.ts +4 -15
- package/package.json +3 -3
- package/src/LiveRatesTableWidget/Main.tsx +44 -51
- package/src/LiveRatesTableWidget/config.ts +27 -10
- package/src/LiveRatesTableWidget/constant.ts +6 -6
- package/src/LiveRatesTableWidget/types.tsx +11 -53
- package/src/LiveRatesTableWidget/utils.ts +21 -65
- package/test/mocks.ts +1 -16
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -96
- package/dist/main/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js +0 -37
- package/dist/main/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js +0 -6
- package/dist/main/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -46
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -6
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -20
- package/dist/main/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -104
- package/dist/main/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js +0 -17
- package/dist/main/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
- package/dist/main/LiveRatesTableWidget/components/index.js +0 -50
- package/dist/main/LiveRatesTableWidget/components/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js +0 -89
- package/dist/module/LiveRatesTableWidget/components/CardWithData/CardWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/CardWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js +0 -30
- package/dist/module/LiveRatesTableWidget/components/Cards/Cards.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/Cards/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/Cards/types.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js +0 -39
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/types.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js +0 -13
- package/dist/module/LiveRatesTableWidget/components/LineChartWithData/utils.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js +0 -97
- package/dist/module/LiveRatesTableWidget/components/RowWithData/RowWithData.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js +0 -2
- package/dist/module/LiveRatesTableWidget/components/RowWithData/index.js.map +0 -1
- package/dist/module/LiveRatesTableWidget/components/index.js +0 -5
- package/dist/module/LiveRatesTableWidget/components/index.js.map +0 -1
- package/dist/types/LiveRatesTableWidget/components/CardWithData/CardWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/CardWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/Cards.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/Cards/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/Cards/types.d.ts +0 -12
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/types.d.ts +0 -11
- package/dist/types/LiveRatesTableWidget/components/LineChartWithData/utils.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/RowWithData/RowWithData.d.ts +0 -4
- package/dist/types/LiveRatesTableWidget/components/RowWithData/index.d.ts +0 -1
- package/dist/types/LiveRatesTableWidget/components/index.d.ts +0 -4
- package/src/LiveRatesTableWidget/components/CardWithData/CardWithData.tsx +0 -133
- package/src/LiveRatesTableWidget/components/CardWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/Cards/Cards.tsx +0 -44
- package/src/LiveRatesTableWidget/components/Cards/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/Cards/types.tsx +0 -13
- package/src/LiveRatesTableWidget/components/LineChartWithData/LineChartWithData.tsx +0 -53
- package/src/LiveRatesTableWidget/components/LineChartWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/LineChartWithData/types.tsx +0 -13
- package/src/LiveRatesTableWidget/components/LineChartWithData/utils.ts +0 -14
- package/src/LiveRatesTableWidget/components/RowWithData/RowWithData.tsx +0 -150
- package/src/LiveRatesTableWidget/components/RowWithData/index.ts +0 -1
- package/src/LiveRatesTableWidget/components/index.ts +0 -4
- package/test/CardWithData.test.tsx +0 -74
- package/test/Cards.test.tsx +0 -130
- package/test/LineChartWithData.test.tsx +0 -263
- package/test/RowWithData.test.tsx +0 -81
|
@@ -1,74 +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 { CardWithData } from '../src/LiveRatesTableWidget/components/CardWithData';
|
|
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
|
-
describe('CardWithData component', () => {
|
|
41
|
-
const record = {
|
|
42
|
-
instrument: 'EUR_USD',
|
|
43
|
-
displayName: 'EUR_USD',
|
|
44
|
-
buy: 1.04508,
|
|
45
|
-
sell: 1.04523,
|
|
46
|
-
spread: 1.2,
|
|
47
|
-
dailyPercentChange: '+3,23%',
|
|
48
|
-
};
|
|
49
|
-
const columns = [
|
|
50
|
-
ColumnsNames.SELL,
|
|
51
|
-
ColumnsNames.BUY,
|
|
52
|
-
ColumnsNames.DAILY_CHANGE,
|
|
53
|
-
ColumnsNames.CHART,
|
|
54
|
-
ColumnsNames.SPREAD,
|
|
55
|
-
];
|
|
56
|
-
it('should render card', () => {
|
|
57
|
-
const { getByTestId, getAllByTestId } = render(
|
|
58
|
-
<MockedProvider mocks={chartPointsMocks}>
|
|
59
|
-
<MockLayoutProvider>
|
|
60
|
-
<CardWithData
|
|
61
|
-
activeColumns={columns}
|
|
62
|
-
division={Division.Oc}
|
|
63
|
-
index={0}
|
|
64
|
-
record={record}
|
|
65
|
-
target={null}
|
|
66
|
-
/>
|
|
67
|
-
</MockLayoutProvider>
|
|
68
|
-
</MockedProvider>
|
|
69
|
-
);
|
|
70
|
-
expect(getByTestId('card')).toBeInTheDocument();
|
|
71
|
-
expect(getByTestId('card-header')).toBeInTheDocument();
|
|
72
|
-
expect(getAllByTestId('card-row').length).toEqual(4);
|
|
73
|
-
});
|
|
74
|
-
});
|
package/test/Cards.test.tsx
DELETED
|
@@ -1,130 +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 { Cards } from '../src/LiveRatesTableWidget/components';
|
|
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
|
-
request: {
|
|
41
|
-
query: getInstrumentsChart,
|
|
42
|
-
variables: {
|
|
43
|
-
instruments: ['EUR_JPY'],
|
|
44
|
-
division: 'OC',
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
result: {
|
|
48
|
-
data: {
|
|
49
|
-
topicalInstrumentsCharts: [
|
|
50
|
-
{
|
|
51
|
-
name: 'EUR_JPY',
|
|
52
|
-
displayName: 'EUR_JPY',
|
|
53
|
-
chart: [
|
|
54
|
-
1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
|
|
55
|
-
1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
|
|
56
|
-
1.05556,
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
describe('Cards component', () => {
|
|
66
|
-
const records = [
|
|
67
|
-
{
|
|
68
|
-
instrument: 'EUR_USD',
|
|
69
|
-
displayName: 'EUR_USD',
|
|
70
|
-
buy: 1.04508,
|
|
71
|
-
sell: 1.04523,
|
|
72
|
-
spread: 1.2,
|
|
73
|
-
dailyPercentChange: '+3,23%',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
instrument: 'EUR_JPY',
|
|
77
|
-
displayName: 'EUR_JPY',
|
|
78
|
-
buy: 1.04553,
|
|
79
|
-
sell: 1.045353,
|
|
80
|
-
spread: 1.3,
|
|
81
|
-
dailyPercentChange: '+4,23%',
|
|
82
|
-
},
|
|
83
|
-
];
|
|
84
|
-
const columns = [
|
|
85
|
-
ColumnsNames.SELL,
|
|
86
|
-
ColumnsNames.BUY,
|
|
87
|
-
ColumnsNames.DAILY_CHANGE,
|
|
88
|
-
ColumnsNames.CHART,
|
|
89
|
-
ColumnsNames.SPREAD,
|
|
90
|
-
];
|
|
91
|
-
it('should render card', () => {
|
|
92
|
-
const { getAllByTestId } = render(
|
|
93
|
-
<MockedProvider mocks={chartPointsMocks}>
|
|
94
|
-
<MockLayoutProvider>
|
|
95
|
-
<Cards
|
|
96
|
-
columns={columns}
|
|
97
|
-
division={Division.Oc}
|
|
98
|
-
emptyCardsCount={2}
|
|
99
|
-
isError={false}
|
|
100
|
-
isLoading={false}
|
|
101
|
-
records={records}
|
|
102
|
-
target={null}
|
|
103
|
-
/>
|
|
104
|
-
</MockLayoutProvider>
|
|
105
|
-
</MockedProvider>
|
|
106
|
-
);
|
|
107
|
-
expect(getAllByTestId('card').length).toEqual(2);
|
|
108
|
-
expect(getAllByTestId('card-header').length).toEqual(2);
|
|
109
|
-
expect(getAllByTestId('card-row').length).toEqual(8);
|
|
110
|
-
});
|
|
111
|
-
it('should render error', () => {
|
|
112
|
-
const { getAllByTestId } = render(
|
|
113
|
-
<MockedProvider mocks={chartPointsMocks}>
|
|
114
|
-
<MockLayoutProvider>
|
|
115
|
-
<Cards
|
|
116
|
-
isError
|
|
117
|
-
columns={columns}
|
|
118
|
-
division={Division.Oc}
|
|
119
|
-
emptyCardsCount={2}
|
|
120
|
-
isLoading={false}
|
|
121
|
-
records={records}
|
|
122
|
-
target={null}
|
|
123
|
-
/>
|
|
124
|
-
</MockLayoutProvider>
|
|
125
|
-
</MockedProvider>
|
|
126
|
-
);
|
|
127
|
-
expect(getAllByTestId('card').length).toEqual(1);
|
|
128
|
-
expect(getAllByTestId('chart-error').length).toEqual(1);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -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
|
-
});
|