Skip to content

Commit 4f6d299

Browse files
committed
[v12] refactor: enable all breaking changes (#1313)
* chore: enable all breaking changes * fix: ci issues * chore: fix lint * chore: cleanup * chore: add migration guide * chore: update docs * chore: docs tweaks * chore: docs tweaks * chore: remove useBreakingChanges config flag * refactor: code review changes * docs: tweaks
1 parent e6cefd9 commit 4f6d299

22 files changed

+124
-1926
lines changed

src/__tests__/__snapshots__/render.breaking.test.tsx.snap

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/__tests__/config.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
} from '../config';
77

88
test('getConfig() returns existing configuration', () => {
9-
expect(getConfig().useBreakingChanges).toEqual(false);
109
expect(getConfig().asyncUtilTimeout).toEqual(1000);
1110
expect(getConfig().defaultIncludeHiddenElements).toEqual(true);
1211
});
@@ -18,7 +17,6 @@ test('configure() overrides existing config values', () => {
1817
asyncUtilTimeout: 5000,
1918
defaultDebugOptions: { message: 'debug message' },
2019
defaultIncludeHiddenElements: true,
21-
useBreakingChanges: false,
2220
});
2321
});
2422

@@ -37,12 +35,12 @@ test('resetToDefaults() resets config to defaults', () => {
3735

3836
test('resetToDefaults() resets internal config to defaults', () => {
3937
configureInternal({
40-
useBreakingChanges: true,
38+
hostComponentNames: { text: 'A', textInput: 'A' },
4139
});
42-
expect(getConfig().useBreakingChanges).toEqual(true);
40+
expect(getConfig().hostComponentNames).toEqual({ text: 'A', textInput: 'A' });
4341

4442
resetToDefaults();
45-
expect(getConfig().useBreakingChanges).toEqual(false);
43+
expect(getConfig().hostComponentNames).toBe(undefined);
4644
});
4745

4846
test('configure handles alias option defaultHidden', () => {

src/__tests__/render.breaking.test.tsx

Lines changed: 0 additions & 247 deletions
This file was deleted.

src/__tests__/render.test.tsx

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
/* eslint-disable no-console */
22
import * as React from 'react';
3-
import { View, Text, TextInput, Pressable, SafeAreaView } from 'react-native';
4-
import { render, fireEvent, RenderAPI } from '..';
5-
6-
type ConsoleLogMock = jest.Mock<typeof console.log>;
7-
8-
beforeEach(() => {
9-
jest.spyOn(console, 'warn').mockImplementation(() => {});
10-
});
3+
import { View, Text, TextInput, Pressable } from 'react-native';
4+
import { render, screen, fireEvent, RenderAPI } from '..';
115

126
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
137
const PLACEHOLDER_CHEF = 'Who inspected freshness?';
@@ -156,7 +150,6 @@ test('unmount should handle cleanup functions', () => {
156150

157151
test('toJSON renders host output', () => {
158152
const { toJSON } = render(<MyButton>press me</MyButton>);
159-
160153
expect(toJSON()).toMatchSnapshot();
161154
});
162155

@@ -226,38 +219,19 @@ test('returns composite UNSAFE_root', () => {
226219
expect(UNSAFE_root.props.testID).toBe('inner');
227220
});
228221

229-
test('returns container', () => {
230-
const { container } = render(<View testID="inner" />);
222+
test('container displays deprecation', () => {
223+
const view = render(<View testID="inner" />);
231224

232-
const mockCalls = (console.warn as any as ConsoleLogMock).mock.calls;
233-
expect(mockCalls[0][0]).toMatchInlineSnapshot(`
234-
"'container' property is deprecated and has been renamed to 'UNSAFE_root'.
225+
expect(() => view.container).toThrowErrorMatchingInlineSnapshot(`
226+
"'container' property has been renamed to 'UNSAFE_root'.
235227
236228
Consider using 'root' property which returns root host element."
237229
`);
230+
expect(() => screen.container).toThrowErrorMatchingInlineSnapshot(`
231+
"'container' property has been renamed to 'UNSAFE_root'.
238232
239-
expect(container).toBeDefined();
240-
// `View` composite component is returned. This behavior will break if we
241-
// start returning only host components.
242-
expect(container.type).toBe(View);
243-
expect(container.props.testID).toBe('inner');
244-
});
245-
246-
test('returns wrapper component as container', () => {
247-
type WrapperComponentProps = { children: React.ReactNode };
248-
const WrapperComponent = ({ children }: WrapperComponentProps) => (
249-
<SafeAreaView testID="wrapper">{children}</SafeAreaView>
250-
);
251-
252-
const { container } = render(<View testID="inner" />, {
253-
wrapper: WrapperComponent,
254-
});
255-
256-
expect(container).toBeDefined();
257-
// `WrapperComponent` composite component is returned with no testID passed to
258-
// it. This behavior will break if we start returning only host components.
259-
expect(container.type).toBe(WrapperComponent);
260-
expect(container.props.testID).not.toBeDefined();
233+
Consider using 'root' property which returns root host element."
234+
`);
261235
});
262236

263237
test('RenderAPI type', () => {

0 commit comments

Comments
 (0)