@oanda/labs-sentiment-widget 1.0.172 → 1.0.173
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 +680 -0
- package/dist/main/SentimentWidget/SentimentWidget.js +15 -20
- package/dist/main/SentimentWidget/SentimentWidget.js.map +1 -1
- package/dist/main/SentimentWidget/Tool.js +1 -1
- package/dist/main/SentimentWidget/Tool.js.map +1 -1
- package/dist/main/SentimentWidget/Widget.js +2 -4
- package/dist/main/SentimentWidget/Widget.js.map +1 -1
- package/dist/main/SentimentWidget/components/SortSwitch/SortSwitch.js +2 -4
- package/dist/main/SentimentWidget/components/SortSwitch/SortSwitch.js.map +1 -1
- package/dist/module/SentimentWidget/SentimentWidget.js +17 -22
- package/dist/module/SentimentWidget/SentimentWidget.js.map +1 -1
- package/dist/module/SentimentWidget/Tool.js +3 -3
- package/dist/module/SentimentWidget/Tool.js.map +1 -1
- package/dist/module/SentimentWidget/Widget.js +3 -3
- package/dist/module/SentimentWidget/Widget.js.map +1 -1
- package/dist/module/SentimentWidget/components/SortSwitch/SortSwitch.js +3 -3
- package/dist/module/SentimentWidget/components/SortSwitch/SortSwitch.js.map +1 -1
- package/package.json +3 -3
- package/src/SentimentWidget/SentimentWidget.tsx +26 -30
- package/src/SentimentWidget/Tool.tsx +3 -3
- package/src/SentimentWidget/Widget.tsx +3 -3
- package/src/SentimentWidget/components/SortSwitch/SortSwitch.tsx +3 -3
- package/test/SortSwitch.test.tsx +30 -21
- package/test/Tool.test.tsx +5 -5
- package/test/Widget.test.tsx +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import {
|
|
4
4
|
Sentiment,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Loader,
|
|
8
8
|
LoaderSize,
|
|
9
9
|
Truncate,
|
|
10
|
-
|
|
10
|
+
useLayoutProvider,
|
|
11
11
|
Size,
|
|
12
12
|
LastUpdated,
|
|
13
13
|
} from '@oanda/labs-widget-common';
|
|
@@ -33,7 +33,7 @@ const Widget = ({
|
|
|
33
33
|
},
|
|
34
34
|
fetchPolicy: 'cache-and-network',
|
|
35
35
|
});
|
|
36
|
-
const { size } =
|
|
36
|
+
const { size } = useLayoutProvider();
|
|
37
37
|
const isDesktop = size === Size.DESKTOP;
|
|
38
38
|
const { lang } = useLocale();
|
|
39
39
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import {
|
|
4
|
-
LongArrowUp, LongArrowDown,
|
|
4
|
+
LongArrowUp, LongArrowDown, useLayoutProvider,
|
|
5
5
|
} from '@oanda/labs-widget-common';
|
|
6
6
|
import { SelectedArrow, SortSwitchProps } from './types';
|
|
7
7
|
|
|
8
8
|
const SortSwitch = ({
|
|
9
9
|
onClickButtonDown, onClickButtonUp, selected, disabled,
|
|
10
10
|
}: SortSwitchProps) => {
|
|
11
|
-
const { isDark } =
|
|
11
|
+
const { isDark } = useLayoutProvider();
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<div
|
package/test/SortSwitch.test.tsx
CHANGED
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render, fireEvent } from '@testing-library/react';
|
|
6
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
6
7
|
import { SortSwitch, SelectedArrow } from '../src/SentimentWidget/components/SortSwitch';
|
|
7
8
|
|
|
8
9
|
describe('SortSwitch component', () => {
|
|
9
10
|
it('should render switch component', () => {
|
|
10
11
|
const { getByTestId } = render(
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
<MockLayoutProvider>
|
|
13
|
+
<SortSwitch
|
|
14
|
+
selected={SelectedArrow.UP}
|
|
15
|
+
onClickButtonDown={() => {}}
|
|
16
|
+
onClickButtonUp={() => {}}
|
|
17
|
+
/>
|
|
18
|
+
</MockLayoutProvider>,
|
|
16
19
|
);
|
|
17
20
|
|
|
18
21
|
expect(getByTestId('sort-switch')).toBeInTheDocument();
|
|
@@ -24,11 +27,13 @@ describe('SortSwitch component', () => {
|
|
|
24
27
|
const onClickDownSpy = jest.fn();
|
|
25
28
|
|
|
26
29
|
const { getByTestId } = render(
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
<MockLayoutProvider>
|
|
31
|
+
<SortSwitch
|
|
32
|
+
selected={SelectedArrow.UP}
|
|
33
|
+
onClickButtonDown={() => onClickDownSpy()}
|
|
34
|
+
onClickButtonUp={() => onClickUpSpy()}
|
|
35
|
+
/>
|
|
36
|
+
</MockLayoutProvider>,
|
|
32
37
|
);
|
|
33
38
|
|
|
34
39
|
fireEvent.click(getByTestId('sort-switch-button-up'));
|
|
@@ -43,11 +48,13 @@ describe('SortSwitch component', () => {
|
|
|
43
48
|
const onClickDownSpy = jest.fn();
|
|
44
49
|
|
|
45
50
|
const { getByTestId } = render(
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
<MockLayoutProvider>
|
|
52
|
+
<SortSwitch
|
|
53
|
+
selected={SelectedArrow.DOWN}
|
|
54
|
+
onClickButtonDown={() => onClickDownSpy()}
|
|
55
|
+
onClickButtonUp={() => onClickUpSpy()}
|
|
56
|
+
/>
|
|
57
|
+
</MockLayoutProvider>,
|
|
51
58
|
);
|
|
52
59
|
|
|
53
60
|
fireEvent.click(getByTestId('sort-switch-button-up'));
|
|
@@ -62,12 +69,14 @@ describe('SortSwitch component', () => {
|
|
|
62
69
|
const onClickDownSpy = jest.fn();
|
|
63
70
|
|
|
64
71
|
const { getByTestId } = render(
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
<MockLayoutProvider>
|
|
73
|
+
<SortSwitch
|
|
74
|
+
disabled
|
|
75
|
+
selected={SelectedArrow.DOWN}
|
|
76
|
+
onClickButtonDown={() => onClickDownSpy()}
|
|
77
|
+
onClickButtonUp={() => onClickUpSpy()}
|
|
78
|
+
/>
|
|
79
|
+
</MockLayoutProvider>,
|
|
71
80
|
);
|
|
72
81
|
|
|
73
82
|
fireEvent.click(getByTestId('sort-switch-button-up'));
|
package/test/Tool.test.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import {
|
|
7
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
8
8
|
import { Tool } from '../src/SentimentWidget/Tool';
|
|
9
9
|
import { getSentimentList } from '../src/gql/getSentimentList';
|
|
10
10
|
import { Division } from '../src/gql/types/graphql';
|
|
@@ -68,9 +68,9 @@ describe('Tool component', () => {
|
|
|
68
68
|
it('should render tool component', async () => {
|
|
69
69
|
const { findByTestId, findAllByTestId } = render(
|
|
70
70
|
<MockedProvider mocks={mocks}>
|
|
71
|
-
<
|
|
71
|
+
<MockLayoutProvider>
|
|
72
72
|
<Tool division={Division.Oc} />
|
|
73
|
-
</
|
|
73
|
+
</MockLayoutProvider>
|
|
74
74
|
</MockedProvider>,
|
|
75
75
|
);
|
|
76
76
|
|
|
@@ -80,9 +80,9 @@ describe('Tool component', () => {
|
|
|
80
80
|
it('should render error', async () => {
|
|
81
81
|
const { findByTestId } = render(
|
|
82
82
|
<MockedProvider mocks={errorMocks}>
|
|
83
|
-
<
|
|
83
|
+
<MockLayoutProvider>
|
|
84
84
|
<Tool division={Division.Oc} />
|
|
85
|
-
</
|
|
85
|
+
</MockLayoutProvider>
|
|
86
86
|
</MockedProvider>,
|
|
87
87
|
);
|
|
88
88
|
|
package/test/Widget.test.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import {
|
|
7
|
+
import { MockLayoutProvider } from '@oanda/labs-widget-common';
|
|
8
8
|
import { Widget } from '../src/SentimentWidget/Widget';
|
|
9
9
|
import { getInstrumentSentiment } from '../src/gql/getInstrumentSentiment';
|
|
10
10
|
import { Division } from '../src/gql/types/graphql';
|
|
@@ -63,9 +63,9 @@ describe('Widget component', () => {
|
|
|
63
63
|
it('should render widget component', async () => {
|
|
64
64
|
const { findByTestId } = render(
|
|
65
65
|
<MockedProvider mocks={mocks}>
|
|
66
|
-
<
|
|
66
|
+
<MockLayoutProvider>
|
|
67
67
|
<Widget division={Division.Oc} instrument="EUR/USD" />
|
|
68
|
-
</
|
|
68
|
+
</MockLayoutProvider>
|
|
69
69
|
</MockedProvider>,
|
|
70
70
|
);
|
|
71
71
|
|
|
@@ -75,9 +75,9 @@ describe('Widget component', () => {
|
|
|
75
75
|
it('should render error when both sentiment values are 0', async () => {
|
|
76
76
|
const { findByTestId } = render(
|
|
77
77
|
<MockedProvider mocks={zeroPercentMocks}>
|
|
78
|
-
<
|
|
78
|
+
<MockLayoutProvider>
|
|
79
79
|
<Widget division={Division.Oc} instrument="GBP/USD" />
|
|
80
|
-
</
|
|
80
|
+
</MockLayoutProvider>
|
|
81
81
|
</MockedProvider>,
|
|
82
82
|
);
|
|
83
83
|
|