@transferwise/components 0.0.0-experimental-11ff1ec → 0.0.0-experimental-e3435b7
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-e3435b7",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"rollup-preserve-directives": "^1.1.1",
|
|
93
93
|
"storybook": "^8.2.2",
|
|
94
94
|
"@transferwise/less-config": "3.1.0",
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
95
|
+
"@transferwise/neptune-css": "14.22.0",
|
|
96
|
+
"@wise/components-theming": "1.6.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"@transferwise/icons": "^3.13.1",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { render } from '../test-utils';
|
|
3
|
+
import withNextPortalWrapper from './withNextPortal';
|
|
4
|
+
|
|
5
|
+
describe('withNextPortalWrapper', () => {
|
|
6
|
+
it('renders component in React portal', () => {
|
|
7
|
+
type Props = Pick<
|
|
8
|
+
HTMLAttributes<HTMLButtonElement>,
|
|
9
|
+
'id' | 'children' | 'className' | 'aria-label'
|
|
10
|
+
>;
|
|
11
|
+
const RandomComponentForTest = withNextPortalWrapper((props: Props) => <span {...props} />);
|
|
12
|
+
const data: Props = {
|
|
13
|
+
'aria-label': 'Test aria-label',
|
|
14
|
+
id: 'random-component',
|
|
15
|
+
children: 'Test Children',
|
|
16
|
+
};
|
|
17
|
+
render(<RandomComponentForTest {...data} />);
|
|
18
|
+
|
|
19
|
+
const componentDomRef = document.body.lastChild;
|
|
20
|
+
expect(componentDomRef).toHaveAttribute('aria-label', data['aria-label']);
|
|
21
|
+
expect(componentDomRef).toHaveTextContent(data.children as string);
|
|
22
|
+
expect(componentDomRef).toHaveAttribute('id', data.id);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { mount } from 'enzyme';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
|
|
4
|
-
import withNextPortal from './withNextPortal';
|
|
5
|
-
|
|
6
|
-
jest.mock('react-dom');
|
|
7
|
-
|
|
8
|
-
describe('withNextPortal', () => {
|
|
9
|
-
it('should return a function', () => {
|
|
10
|
-
expect(typeof withNextPortal()).toBe('function');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('should create a portal with the component', () => {
|
|
14
|
-
ReactDOM.createPortal.mockImplementation(() => null);
|
|
15
|
-
const props = {};
|
|
16
|
-
const Component = withNextPortal(AnyComponent);
|
|
17
|
-
mount(<Component {...props} />);
|
|
18
|
-
expect(ReactDOM.createPortal).toHaveBeenCalledTimes(1);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const AnyComponent = () => <div>Test div</div>;
|
|
22
|
-
});
|