|
1 | 1 | /* eslint-disable no-console */
|
2 | 2 | import * as React from 'react';
|
3 |
| -import { View, Text, TextInput, Pressable, SafeAreaView } from 'react-native'; |
4 |
| -import { render, fireEvent, RenderAPI } from '..'; |
5 |
| - |
6 |
| -beforeEach(() => { |
7 |
| - jest.spyOn(console, 'warn').mockImplementation(() => {}); |
8 |
| -}); |
| 3 | +import { View, Text, TextInput, Pressable } from 'react-native'; |
| 4 | +import { render, screen, fireEvent, RenderAPI } from '..'; |
9 | 5 |
|
10 | 6 | const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
|
11 | 7 | const PLACEHOLDER_CHEF = 'Who inspected freshness?';
|
@@ -154,7 +150,6 @@ test('unmount should handle cleanup functions', () => {
|
154 | 150 |
|
155 | 151 | test('toJSON renders host output', () => {
|
156 | 152 | const { toJSON } = render(<MyButton>press me</MyButton>);
|
157 |
| - |
158 | 153 | expect(toJSON()).toMatchSnapshot();
|
159 | 154 | });
|
160 | 155 |
|
@@ -224,31 +219,19 @@ test('returns composite UNSAFE_root', () => {
|
224 | 219 | expect(UNSAFE_root.props.testID).toBe('inner');
|
225 | 220 | });
|
226 | 221 |
|
227 |
| -test('returns container', () => { |
228 |
| - const { container } = render(<View testID="inner" />); |
| 222 | +test('container displays deprecation', () => { |
| 223 | + const view = render(<View testID="inner" />); |
229 | 224 |
|
230 |
| - expect(container).toBeDefined(); |
231 |
| - // `View` composite component is returned. This behavior will break if we |
232 |
| - // start returning only host components. |
233 |
| - expect(container.type).toBe(View); |
234 |
| - expect(container.props.testID).toBe('inner'); |
235 |
| -}); |
236 |
| - |
237 |
| -test('returns wrapper component as container', () => { |
238 |
| - type WrapperComponentProps = { children: React.ReactNode }; |
239 |
| - const WrapperComponent = ({ children }: WrapperComponentProps) => ( |
240 |
| - <SafeAreaView testID="wrapper">{children}</SafeAreaView> |
241 |
| - ); |
| 225 | + expect(() => view.container).toThrowErrorMatchingInlineSnapshot(` |
| 226 | + "'container' property has been renamed to 'UNSAFE_root'. |
242 | 227 |
|
243 |
| - const { container } = render(<View testID="inner" />, { |
244 |
| - wrapper: WrapperComponent, |
245 |
| - }); |
| 228 | + Consider using 'root' property which returns root host element." |
| 229 | + `); |
| 230 | + expect(() => screen.container).toThrowErrorMatchingInlineSnapshot(` |
| 231 | + "'container' property has been renamed to 'UNSAFE_root'. |
246 | 232 |
|
247 |
| - expect(container).toBeDefined(); |
248 |
| - // `WrapperComponent` composite component is returned with no testID passed to |
249 |
| - // it. This behavior will break if we start returning only host components. |
250 |
| - expect(container.type).toBe(WrapperComponent); |
251 |
| - expect(container.props.testID).not.toBeDefined(); |
| 233 | + Consider using 'root' property which returns root host element." |
| 234 | + `); |
252 | 235 | });
|
253 | 236 |
|
254 | 237 | test('RenderAPI type', () => {
|
|
0 commit comments