piral-core 0.15.0-alpha.4355 → 0.15.0-alpha.4396
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": "piral-core",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.4396",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"piral-base": "0.15.0-alpha.
|
|
75
|
-
"piral-debug-utils": "0.15.0-alpha.
|
|
74
|
+
"piral-base": "0.15.0-alpha.4396",
|
|
75
|
+
"piral-debug-utils": "0.15.0-alpha.4396",
|
|
76
76
|
"zustand": "^3.0.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"history",
|
|
101
101
|
"tslib"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "62abff4d61634b3ecffda2407f1c29f1de929b4c"
|
|
104
104
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render } from 'react-dom';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
4
|
import { RootListener } from './RootListener';
|
|
5
5
|
|
|
@@ -10,7 +10,7 @@ jest.mock('./hooks/globalState', () => ({
|
|
|
10
10
|
}));
|
|
11
11
|
|
|
12
12
|
function resolveAfter(time = 5) {
|
|
13
|
-
return new Promise<void>(resolve => setTimeout(resolve, time));
|
|
13
|
+
return new Promise<void>((resolve) => setTimeout(resolve, time));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
describe('RootListener Component', () => {
|
|
@@ -19,8 +19,7 @@ describe('RootListener Component', () => {
|
|
|
19
19
|
const removed = jest.fn();
|
|
20
20
|
document.body.appendChild(element);
|
|
21
21
|
const container = document.body.appendChild(document.createElement('div'));
|
|
22
|
-
|
|
23
|
-
root.render(<RootListener />);
|
|
22
|
+
render(<RootListener />, container);
|
|
24
23
|
document.body.removeEventListener = removed;
|
|
25
24
|
await act(() => {
|
|
26
25
|
const event = new CustomEvent('render-html', {
|
|
@@ -40,11 +39,10 @@ describe('RootListener Component', () => {
|
|
|
40
39
|
it('removes the RootListener successfully', async () => {
|
|
41
40
|
const container = document.body.appendChild(document.createElement('div'));
|
|
42
41
|
const removed = jest.fn();
|
|
43
|
-
|
|
44
|
-
root.render(<RootListener />);
|
|
42
|
+
render(<RootListener />, container);
|
|
45
43
|
document.body.removeEventListener = removed;
|
|
46
44
|
await act(resolveAfter);
|
|
47
|
-
|
|
45
|
+
render(<div />, container);
|
|
48
46
|
await act(resolveAfter);
|
|
49
47
|
expect(removed).toHaveBeenCalled();
|
|
50
48
|
});
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { render as renderDom } from 'react-dom';
|
|
3
3
|
import { act } from 'react-dom/test-utils';
|
|
4
4
|
import { ForeignComponentContainer } from './ForeignComponentContainer';
|
|
5
5
|
|
|
6
6
|
function resolveAfter(time = 5) {
|
|
7
|
-
return new Promise<void>(resolve => setTimeout(resolve, time));
|
|
7
|
+
return new Promise<void>((resolve) => setTimeout(resolve, time));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async function render(element: any, container: Element) {
|
|
11
|
-
|
|
12
|
-
root.render(element);
|
|
11
|
+
renderDom(element, container);
|
|
13
12
|
await act(resolveAfter);
|
|
14
|
-
return
|
|
13
|
+
return () => renderDom(<div />, container);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
describe('ForeignComponentContainer component', () => {
|
|
@@ -32,13 +31,13 @@ describe('ForeignComponentContainer component', () => {
|
|
|
32
31
|
const mount = jest.fn();
|
|
33
32
|
const unmount = jest.fn();
|
|
34
33
|
const component = { mount, unmount };
|
|
35
|
-
const
|
|
34
|
+
const doUnmount = await render(
|
|
36
35
|
<ForeignComponentContainer $component={component} $context={undefined} $portalId="foo" innerProps={{}} />,
|
|
37
36
|
container,
|
|
38
37
|
);
|
|
39
38
|
expect(mount).toHaveBeenCalled();
|
|
40
39
|
expect(unmount).not.toHaveBeenCalled();
|
|
41
|
-
|
|
40
|
+
doUnmount();
|
|
42
41
|
expect(unmount).toHaveBeenCalled();
|
|
43
42
|
container.remove();
|
|
44
43
|
});
|
|
@@ -48,7 +47,7 @@ describe('ForeignComponentContainer component', () => {
|
|
|
48
47
|
const mount = jest.fn();
|
|
49
48
|
const update = jest.fn();
|
|
50
49
|
const component = { mount, update };
|
|
51
|
-
|
|
50
|
+
await render(
|
|
52
51
|
<ForeignComponentContainer
|
|
53
52
|
$component={component}
|
|
54
53
|
$context={undefined}
|
|
@@ -59,13 +58,14 @@ describe('ForeignComponentContainer component', () => {
|
|
|
59
58
|
);
|
|
60
59
|
expect(mount).toHaveBeenCalled();
|
|
61
60
|
expect(update).not.toHaveBeenCalled();
|
|
62
|
-
|
|
61
|
+
await render(
|
|
63
62
|
<ForeignComponentContainer
|
|
64
63
|
$component={component}
|
|
65
64
|
$context={undefined}
|
|
66
65
|
$portalId="foo"
|
|
67
66
|
innerProps={{ a: 'foo' }}
|
|
68
67
|
/>,
|
|
68
|
+
container,
|
|
69
69
|
);
|
|
70
70
|
await act(resolveAfter);
|
|
71
71
|
expect(update).toHaveBeenCalled();
|
|
@@ -78,14 +78,14 @@ describe('ForeignComponentContainer component', () => {
|
|
|
78
78
|
ForeignComponentContainer.prototype.componentDidMount = function () {
|
|
79
79
|
componentDidMount.call(this);
|
|
80
80
|
this.previous = {
|
|
81
|
-
removeEventListener() {
|
|
81
|
+
removeEventListener() {},
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
const mount = jest.fn();
|
|
85
85
|
const update = jest.fn();
|
|
86
86
|
const unmount = jest.fn();
|
|
87
87
|
const component = { mount, update, unmount };
|
|
88
|
-
|
|
88
|
+
await render(
|
|
89
89
|
<ForeignComponentContainer
|
|
90
90
|
$component={component}
|
|
91
91
|
$context={undefined}
|
|
@@ -97,13 +97,14 @@ describe('ForeignComponentContainer component', () => {
|
|
|
97
97
|
expect(mount).toHaveBeenCalled();
|
|
98
98
|
expect(unmount).not.toHaveBeenCalled();
|
|
99
99
|
expect(update).not.toHaveBeenCalled();
|
|
100
|
-
|
|
100
|
+
await render(
|
|
101
101
|
<ForeignComponentContainer
|
|
102
102
|
$component={component}
|
|
103
103
|
$context={undefined}
|
|
104
104
|
$portalId="foo"
|
|
105
105
|
innerProps={{ a: 'foo' }}
|
|
106
106
|
/>,
|
|
107
|
+
container,
|
|
107
108
|
);
|
|
108
109
|
await act(resolveAfter);
|
|
109
110
|
expect(update).not.toHaveBeenCalled();
|
|
@@ -124,7 +125,7 @@ describe('ForeignComponentContainer component', () => {
|
|
|
124
125
|
expect(mount).toHaveBeenCalled();
|
|
125
126
|
const node = document.querySelector('[data-portal-id=foo]');
|
|
126
127
|
expect(renderHtmlExtension).not.toHaveBeenCalled();
|
|
127
|
-
node
|
|
128
|
+
node?.dispatchEvent(new CustomEvent('render-html', { detail: {} }));
|
|
128
129
|
await act(resolveAfter);
|
|
129
130
|
expect(renderHtmlExtension).toHaveBeenCalled();
|
|
130
131
|
container.remove();
|
package/src/hooks/setter.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { act } from 'react-dom/test-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { render } from 'react-dom';
|
|
4
4
|
import { useSetter } from './setter';
|
|
5
5
|
|
|
6
6
|
describe('UseSetter Hook Module', () => {
|
|
@@ -12,9 +12,8 @@ describe('UseSetter Hook Module', () => {
|
|
|
12
12
|
return null;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
await act(() => new Promise(resolve => setTimeout(resolve, 5)));
|
|
15
|
+
render(React.createElement(MyComponent), document.body.appendChild(document.createElement('div')));
|
|
16
|
+
await act(() => new Promise((resolve) => setTimeout(resolve, 5)));
|
|
18
17
|
expect(cb).toHaveBeenCalled();
|
|
19
18
|
});
|
|
20
19
|
});
|