Skip to content

Commit 9b95bd5

Browse files
committed
reduce toJSON usage
1 parent cf26b90 commit 9b95bd5

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/__tests__/react-native-api.test.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { mapJsonProps } from '../test-utils/json';
1212
test('React Native API assumption: <View> renders a single host element', () => {
1313
render(<View testID="test" />);
1414

15-
expect(screen.toJSON()).toMatchInlineSnapshot(`
15+
expect(screen).toMatchInlineSnapshot(`
1616
<>
1717
<View
1818
testID="test"
@@ -24,7 +24,7 @@ test('React Native API assumption: <View> renders a single host element', () =>
2424
test('React Native API assumption: <Text> renders a single host element', () => {
2525
render(<Text testID="test">Hello</Text>);
2626

27-
expect(screen.toJSON()).toMatchInlineSnapshot(`
27+
expect(screen).toMatchInlineSnapshot(`
2828
<>
2929
<Text
3030
testID="test"
@@ -46,7 +46,7 @@ test('React Native API assumption: nested <Text> renders a single host element',
4646
</Text>,
4747
);
4848

49-
expect(screen.toJSON()).toMatchInlineSnapshot(`
49+
expect(screen).toMatchInlineSnapshot(`
5050
<>
5151
<Text
5252
testID="test"
@@ -81,7 +81,7 @@ test('React Native API assumption: <TextInput> renders a single host element', (
8181
/>,
8282
);
8383

84-
expect(screen.toJSON()).toMatchInlineSnapshot(`
84+
expect(screen).toMatchInlineSnapshot(`
8585
<>
8686
<TextInput
8787
defaultValue="default"
@@ -100,7 +100,7 @@ test('React Native API assumption: <TextInput> with nested Text renders single h
100100
</TextInput>,
101101
);
102102

103-
expect(screen.toJSON()).toMatchInlineSnapshot(`
103+
expect(screen).toMatchInlineSnapshot(`
104104
<>
105105
<TextInput
106106
placeholder="Placeholder"
@@ -143,7 +143,7 @@ test('React Native API assumption: <Switch> renders a single host element', () =
143143
test('React Native API assumption: <Image> renders a single host element', () => {
144144
render(<Image testID="test" source={{ uri: 'https://fake.url/image.jpg' }} alt="Alt text" />);
145145

146-
expect(screen.toJSON()).toMatchInlineSnapshot(`
146+
expect(screen).toMatchInlineSnapshot(`
147147
<>
148148
<Image
149149
alt="Alt text"
@@ -165,7 +165,7 @@ test('React Native API assumption: <ScrollView> renders a single host element',
165165
</ScrollView>,
166166
);
167167

168-
expect(screen.toJSON()).toMatchInlineSnapshot(`
168+
expect(screen).toMatchInlineSnapshot(`
169169
<>
170170
<RCTScrollView
171171
testID="scrollView"
@@ -185,7 +185,7 @@ test('React Native API assumption: <FlatList> renders a single host <ScrollView>
185185
<FlatList testID="flatList" data={[1, 2]} renderItem={({ item }) => <Text>{item}</Text>} />,
186186
);
187187

188-
expect(screen.toJSON()).toMatchInlineSnapshot(`
188+
expect(screen).toMatchInlineSnapshot(`
189189
<>
190190
<RCTScrollView
191191
data={
@@ -243,7 +243,7 @@ test('React Native API assumption: <Modal> renders a single host element', () =>
243243
</Modal>,
244244
);
245245

246-
expect(screen.toJSON()).toMatchInlineSnapshot(`
246+
expect(screen).toMatchInlineSnapshot(`
247247
<>
248248
<Modal
249249
testID="test"
@@ -280,7 +280,7 @@ test('React Native API assumption: aria-* props render directly on host View', (
280280
/>,
281281
);
282282

283-
expect(screen.toJSON()).toMatchInlineSnapshot(`
283+
expect(screen).toMatchInlineSnapshot(`
284284
<>
285285
<View
286286
aria-busy={true}
@@ -330,7 +330,7 @@ test('React Native API assumption: aria-* props render directly on host Text', (
330330
/>,
331331
);
332332

333-
expect(screen.toJSON()).toMatchInlineSnapshot(`
333+
expect(screen).toMatchInlineSnapshot(`
334334
<>
335335
<Text
336336
aria-busy={true}
@@ -380,7 +380,7 @@ test('React Native API assumption: aria-* props render directly on host TextInpu
380380
/>,
381381
);
382382

383-
expect(screen.toJSON()).toMatchInlineSnapshot(`
383+
expect(screen).toMatchInlineSnapshot(`
384384
<>
385385
<TextInput
386386
aria-busy={true}

src/__tests__/render.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test('unmount should handle cleanup functions', () => {
114114

115115
test('toJSON renders host output', () => {
116116
render(<MyButton>press me</MyButton>);
117-
expect(screen.toJSON()).toMatchSnapshot();
117+
expect(screen).toMatchSnapshot();
118118
});
119119

120120
test('renders options.wrapper around node', () => {
@@ -128,7 +128,7 @@ test('renders options.wrapper around node', () => {
128128
});
129129

130130
expect(screen.getByTestId('wrapper')).toBeTruthy();
131-
expect(screen.toJSON()).toMatchInlineSnapshot(`
131+
expect(screen).toMatchInlineSnapshot(`
132132
<>
133133
<View
134134
testID="wrapper"
@@ -154,7 +154,7 @@ test('renders options.wrapper around updated node', () => {
154154
screen.rerender(<View testID="inner" accessibilityLabel="test" accessibilityHint="test" />);
155155

156156
expect(screen.getByTestId('wrapper')).toBeTruthy();
157-
expect(screen.toJSON()).toMatchInlineSnapshot(`
157+
expect(screen).toMatchInlineSnapshot(`
158158
<>
159159
<View
160160
testID="wrapper"

0 commit comments

Comments
 (0)