@oanda/labs-instrument-live-rate-widget 1.0.1
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 +8 -0
- package/codegen.ts +15 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +56 -0
- package/dist/main/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js +77 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +83 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +28 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +25 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +44 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js +17 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js +6 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js +17 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/constant.js +8 -0
- package/dist/main/InstrumentLiveRateWidget/constant.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/render.js +51 -0
- package/dist/main/InstrumentLiveRateWidget/render.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/types.js +20 -0
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/utils.js +43 -0
- package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -0
- package/dist/main/gql/getInstrumentsChart.js +16 -0
- package/dist/main/gql/getInstrumentsChart.js.map +1 -0
- package/dist/main/gql/types/fragment-masking.js +23 -0
- package/dist/main/gql/types/fragment-masking.js.map +1 -0
- package/dist/main/gql/types/gql.js +17 -0
- package/dist/main/gql/types/gql.js.map +1 -0
- package/dist/main/gql/types/graphql.js +326 -0
- package/dist/main/gql/types/graphql.js.map +1 -0
- package/dist/main/gql/types/index.js +28 -0
- package/dist/main/gql/types/index.js.map +1 -0
- package/dist/main/gql/validateInstruments.js +16 -0
- package/dist/main/gql/validateInstruments.js.map +1 -0
- package/dist/main/index.js +28 -0
- package/dist/main/index.js.map +1 -0
- package/dist/main/translations/index.js +27 -0
- package/dist/main/translations/index.js.map +1 -0
- package/dist/main/translations/sources/en.json +4 -0
- package/dist/main/translations/sources/es.json +4 -0
- package/dist/main/translations/sources/th.json +4 -0
- package/dist/main/translations/sources/zh_TW.json +4 -0
- package/dist/main/translations/translations.js +11 -0
- package/dist/main/translations/translations.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js +49 -0
- package/dist/module/InstrumentLiveRateWidget/InstrumentLiveRateWidget.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/Main.js +69 -0
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +74 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js +18 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +37 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/constant.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/constant.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/render.js +48 -0
- package/dist/module/InstrumentLiveRateWidget/render.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/types.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/utils.js +36 -0
- package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -0
- package/dist/module/gql/getInstrumentsChart.js +10 -0
- package/dist/module/gql/getInstrumentsChart.js.map +1 -0
- package/dist/module/gql/types/fragment-masking.js +15 -0
- package/dist/module/gql/types/fragment-masking.js.map +1 -0
- package/dist/module/gql/types/gql.js +9 -0
- package/dist/module/gql/types/gql.js.map +1 -0
- package/dist/module/gql/types/graphql.js +320 -0
- package/dist/module/gql/types/graphql.js.map +1 -0
- package/dist/module/gql/types/index.js +3 -0
- package/dist/module/gql/types/index.js.map +1 -0
- package/dist/module/gql/validateInstruments.js +10 -0
- package/dist/module/gql/validateInstruments.js.map +1 -0
- package/dist/module/index.js +3 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/translations/index.js +20 -0
- package/dist/module/translations/index.js.map +1 -0
- package/dist/module/translations/sources/en.json +4 -0
- package/dist/module/translations/sources/es.json +4 -0
- package/dist/module/translations/sources/th.json +4 -0
- package/dist/module/translations/sources/zh_TW.json +4 -0
- package/dist/module/translations/translations.js +5 -0
- package/dist/module/translations/translations.js.map +1 -0
- package/dist/types/InstrumentLiveRateWidget/InstrumentLiveRateWidget.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/Main.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.d.ts +3 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +11 -0
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/constant.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/render.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +43 -0
- package/dist/types/InstrumentLiveRateWidget/utils.d.ts +12 -0
- package/dist/types/gql/getInstrumentsChart.d.ts +1 -0
- package/dist/types/gql/types/fragment-masking.d.ts +15 -0
- package/dist/types/gql/types/gql.d.ts +45 -0
- package/dist/types/gql/types/graphql.d.ts +397 -0
- package/dist/types/gql/types/index.d.ts +2 -0
- package/dist/types/gql/validateInstruments.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/translations/index.d.ts +4 -0
- package/dist/types/translations/translations.d.ts +4 -0
- package/index.ts +1 -0
- package/lokalise.config.json +18 -0
- package/package.json +25 -0
- package/src/InstrumentLiveRateWidget/InstrumentLiveRateWidget.tsx +57 -0
- package/src/InstrumentLiveRateWidget/Main.tsx +82 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +92 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +2 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.ts +25 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +48 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +12 -0
- package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/constant.ts +5 -0
- package/src/InstrumentLiveRateWidget/render.tsx +48 -0
- package/src/InstrumentLiveRateWidget/types.tsx +50 -0
- package/src/InstrumentLiveRateWidget/utils.ts +49 -0
- package/src/gql/getInstrumentsChart.ts +10 -0
- package/src/gql/types/fragment-masking.ts +66 -0
- package/src/gql/types/gql.ts +47 -0
- package/src/gql/types/graphql.ts +432 -0
- package/src/gql/types/index.ts +2 -0
- package/src/gql/validateInstruments.ts +10 -0
- package/src/index.ts +2 -0
- package/src/translations/index.ts +17 -0
- package/src/translations/sources/en.json +4 -0
- package/src/translations/sources/es.json +4 -0
- package/src/translations/sources/th.json +4 -0
- package/src/translations/sources/zh_TW.json +4 -0
- package/src/translations/translations.ts +4 -0
- package/test/LineChartWithData.test.tsx +164 -0
- package/test/Main.test.tsx +27 -0
- package/test/components/InstrumentRateWithData.test.tsx +62 -0
- package/test/components/utils.test.ts +13 -0
- package/test/mocks.ts +52 -0
- package/tsconfig.types.json +12 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
+
import { InstrumentRateWithData } from '../../src/InstrumentLiveRateWidget/components/InstrumentRateWithData';
|
|
8
|
+
import { getInstrumentsChart } from '../../src/gql/getInstrumentsChart';
|
|
9
|
+
import { Division } from '../../src/gql/types/graphql';
|
|
10
|
+
|
|
11
|
+
const chartPointsMocks = [
|
|
12
|
+
{
|
|
13
|
+
request: {
|
|
14
|
+
query: getInstrumentsChart,
|
|
15
|
+
variables: {
|
|
16
|
+
instruments: ['EUR_USD'],
|
|
17
|
+
division: 'OC',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
result: {
|
|
21
|
+
data: {
|
|
22
|
+
topicalInstrumentsCharts: [
|
|
23
|
+
{
|
|
24
|
+
name: 'EUR_USD',
|
|
25
|
+
displayName: 'EUR_USD',
|
|
26
|
+
chart: [
|
|
27
|
+
1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
|
|
28
|
+
1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
|
|
29
|
+
1.05556,
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
describe('InstrumentRateWithData component', () => {
|
|
39
|
+
const record = {
|
|
40
|
+
instrument: 'EUR_USD',
|
|
41
|
+
displayName: 'EUR_USD',
|
|
42
|
+
buy: 1.04508,
|
|
43
|
+
dailyPercentChange: '+3,23%',
|
|
44
|
+
dailyPipsChange: 123,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
it('should render table row', async () => {
|
|
48
|
+
const { getAllByTestId, findByTestId } = render(
|
|
49
|
+
<MockedProvider mocks={chartPointsMocks}>
|
|
50
|
+
<InstrumentRateWithData
|
|
51
|
+
loading={false}
|
|
52
|
+
division={Division.Oc}
|
|
53
|
+
record={record}
|
|
54
|
+
target={null}
|
|
55
|
+
/>
|
|
56
|
+
</MockedProvider>,
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(await findByTestId('line-chart')).toBeInTheDocument();
|
|
60
|
+
expect(getAllByTestId('label-wrapper').length).toEqual(4);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { getColorIndicator } from '../../src/InstrumentLiveRateWidget/components/InstrumentRateWithData';
|
|
2
|
+
|
|
3
|
+
describe('getColorIndicator', () => {
|
|
4
|
+
it('should return value greater than 0', () => {
|
|
5
|
+
expect(getColorIndicator('+0.06%')).toEqual(1);
|
|
6
|
+
});
|
|
7
|
+
it('should return value equal to 0', () => {
|
|
8
|
+
expect(getColorIndicator('0%')).toEqual(0);
|
|
9
|
+
});
|
|
10
|
+
it('should return value lower than 0', () => {
|
|
11
|
+
expect(getColorIndicator('-0.20%')).toEqual(-1);
|
|
12
|
+
});
|
|
13
|
+
});
|
package/test/mocks.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getInstrumentsChart } from '../src/gql/getInstrumentsChart';
|
|
2
|
+
import { validateInstruments } from '../src/gql/validateInstruments';
|
|
3
|
+
|
|
4
|
+
const widgetMocks = [
|
|
5
|
+
{
|
|
6
|
+
request: {
|
|
7
|
+
query: validateInstruments,
|
|
8
|
+
variables: {
|
|
9
|
+
instruments: ['EUR_USD'],
|
|
10
|
+
division: 'OC',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
result: {
|
|
14
|
+
data: {
|
|
15
|
+
mapInstrumentNames: [
|
|
16
|
+
{
|
|
17
|
+
name: 'EUR_USD',
|
|
18
|
+
displayName: 'EUR/USD',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
request: {
|
|
26
|
+
query: getInstrumentsChart,
|
|
27
|
+
variables: {
|
|
28
|
+
instruments: ['EUR_USD'],
|
|
29
|
+
division: 'OC',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
result: {
|
|
33
|
+
data: {
|
|
34
|
+
topicalInstrumentsCharts: [
|
|
35
|
+
{
|
|
36
|
+
name: 'EUR_USD',
|
|
37
|
+
displayName: 'EUR/USD',
|
|
38
|
+
chart: [
|
|
39
|
+
1.0544, 1.05704, 1.05716, 1.05596, 1.05556, 1.05556, 1.05238,
|
|
40
|
+
1.05292, 1.05443, 1.0544, 1.05704, 1.05716, 1.05596, 1.05556,
|
|
41
|
+
1.05556,
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
widgetMocks,
|
|
52
|
+
};
|