-
Notifications
You must be signed in to change notification settings - Fork 278
Expand file tree
/
Copy pathhost-component-names.test.tsx
More file actions
48 lines (41 loc) · 1.33 KB
/
host-component-names.test.tsx
File metadata and controls
48 lines (41 loc) · 1.33 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
import * as React from 'react';
import { Image, Modal, ScrollView, Switch, Text, TextInput } from 'react-native';
import {
isHostImage,
isHostModal,
isHostScrollView,
isHostSwitch,
isHostText,
isHostTextInput,
} from '../helpers/host-component-names';
import { render, screen } from '..';
test('detects host Text component', () => {
render(<Text>Hello</Text>);
expect(isHostText(screen.root)).toBe(true);
});
// Some users might use the raw RCTText component directly for performance reasons.
// See: https://blog.theodo.com/2023/10/native-views-rn-performance/
test('detects raw RCTText component', () => {
render(React.createElement('RCTText', { testID: 'text' }, 'Hello'));
expect(isHostText(screen.root)).toBe(true);
});
test('detects host TextInput component', () => {
render(<TextInput />);
expect(isHostTextInput(screen.root)).toBe(true);
});
test('detects host Image component', () => {
render(<Image />);
expect(isHostImage(screen.root)).toBe(true);
});
test('detects host Switch component', () => {
render(<Switch />);
expect(isHostSwitch(screen.root)).toBe(true);
});
test('detects host ScrollView component', () => {
render(<ScrollView />);
expect(isHostScrollView(screen.root)).toBe(true);
});
test('detects host Modal component', () => {
render(<Modal />);
expect(isHostModal(screen.root)).toBe(true);
});