-
Notifications
You must be signed in to change notification settings - Fork 3
/
Component.portal.test.tsx
38 lines (32 loc) · 1.08 KB
/
Component.portal.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Cascade from '../cascade/Cascade';
import { Component } from './Component';
import Portal from './Portal';
describe('Component.portal', () => {
it('should render Components to specified Element', async () => {
var container = document.createElement('div');
var portalContainer = document.createElement('div');
class Parent extends Component<any> {
render() {
return (
<div>
<Child />
</div>
);
}
}
class Child extends Component<any> {
render() {
return (
<Portal element={portalContainer}>
<div>Child</div>
</Portal>
);
}
}
var root = <Parent />;
var container = document.createElement('div');
Cascade.render(container, root);
expect(container.childNodes[0].textContent).toBe('');
expect(portalContainer.childNodes[0].textContent).toBe('Child');
});
});