-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.test.jsx
66 lines (61 loc) · 1.37 KB
/
index.test.jsx
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { PortalProvider, WhitePortal, BlackPortal } from '.';
configure({ adapter: new Adapter() });
const YourApp = () => <div>ok</div>;
test('smoke test', () => {
const wrapper = mount(
<PortalProvider>
<YourApp />
</PortalProvider>
);
expect(wrapper.contains('ok')).toBeTruthy();
wrapper.unmount();
});
test('basic', () => {
const wrapper = mount(
<PortalProvider>
<div>
a
<WhitePortal name="one" />
b
<BlackPortal name="one">1</BlackPortal>
c
</div>
</PortalProvider>
);
expect(wrapper.text()).toBe('a1bc');
wrapper.unmount();
});
test('name mismatch', () => {
const wrapper = mount(
<PortalProvider>
<div>
a
<WhitePortal name="two" />
b
<BlackPortal name="one">1</BlackPortal>
c
</div>
</PortalProvider>
);
expect(wrapper.text()).toBe('abc');
wrapper.unmount();
});
test('multiple WhitePortal', () => {
const wrapper = mount(
<PortalProvider>
<div>
a
<WhitePortal name="one" />
<WhitePortal name="one" />
b
<BlackPortal name="one">1</BlackPortal>
c
</div>
</PortalProvider>
);
expect(wrapper.text()).toBe('a11bc');
wrapper.unmount();
});