-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathcomponent-tree.test.tsx
More file actions
52 lines (46 loc) · 1.32 KB
/
component-tree.test.tsx
File metadata and controls
52 lines (46 loc) · 1.32 KB
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
import React from 'react';
import { View } from 'react-native';
import { render, screen } from '../..';
import { getContainerElement, getInstanceSiblings } from '../component-tree';
function MultipleHostChildren() {
return (
<>
<View testID="child1" />
<View testID="child2" />
<View testID="child3" />
</>
);
}
describe('getHostSiblings()', () => {
it('returns host siblings for host component', async () => {
await render(
<View testID="grandparent">
<View testID="parent">
<View testID="siblingBefore" />
<View testID="subject" />
<View testID="siblingAfter" />
<MultipleHostChildren />
</View>
</View>,
);
const hostSiblings = getInstanceSiblings(screen.getByTestId('subject'));
expect(hostSiblings).toEqual([
screen.getByTestId('siblingBefore'),
screen.getByTestId('siblingAfter'),
screen.getByTestId('child1'),
screen.getByTestId('child2'),
screen.getByTestId('child3'),
]);
});
});
describe('getContainerElement()', () => {
it('returns container for mounted view', async () => {
await render(
<View>
<View testID="view" />
</View>,
);
const view = screen.getByTestId('view');
expect(getContainerElement(view)).toEqual(screen.container);
});
});