forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
react-next.diff
200 lines (192 loc) · 9.47 KB
/
react-next.diff
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
index af7e296af..144de6de4 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.test.js
@@ -1109,8 +1109,6 @@ describe('<Autocomplete />', () => {
fireEvent.change(textbox, { target: { value: 'a' } });
fireEvent.keyDown(textbox, { key: 'Enter' });
}).toErrorDev([
- 'Material-UI: The `getOptionLabel` method of Autocomplete returned undefined instead of a string',
- // strict mode renders twice
'Material-UI: The `getOptionLabel` method of Autocomplete returned undefined instead of a string',
'Material-UI: The `getOptionLabel` method of Autocomplete returned undefined instead of a string',
'Material-UI: The `getOptionLabel` method of Autocomplete returned undefined instead of a string',
@@ -1165,9 +1163,6 @@ describe('<Autocomplete />', () => {
/>,
);
}).toWarnDev([
- 'None of the options match with `"not a good value"`',
- // strict mode renders twice
- 'None of the options match with `"not a good value"`',
'None of the options match with `"not a good value"`',
'None of the options match with `"not a good value"`',
]);
@@ -1193,11 +1188,7 @@ describe('<Autocomplete />', () => {
groupBy={(option) => option.group}
/>,
);
- }).toWarnDev([
- // strict mode renders twice
- 'returns duplicated headers',
- 'returns duplicated headers',
- ]);
+ }).toWarnDev(['returns duplicated headers']);
const options = screen.getAllByRole('option').map((el) => el.textContent);
expect(options).to.have.length(7);
expect(options).to.deep.equal(['A', 'D', 'E', 'B', 'G', 'F', 'C']);
diff --git a/packages/material-ui-styles/src/ThemeProvider/ThemeProvider.test.js b/packages/material-ui-styles/src/ThemeProvider/ThemeProvider.test.js
index 46238825d..bcf275893 100644
--- a/packages/material-ui-styles/src/ThemeProvider/ThemeProvider.test.js
+++ b/packages/material-ui-styles/src/ThemeProvider/ThemeProvider.test.js
@@ -127,11 +127,7 @@ describe('ThemeProvider', () => {
<div />
</ThemeProvider>,
);
- }).toErrorDev([
- 'However, no outer theme is present.',
- // strict mode renders twice
- 'However, no outer theme is present.',
- ]);
+ }).toErrorDev(['However, no outer theme is present.']);
});
it('should warn about wrong theme function', () => {
@@ -144,11 +140,7 @@ describe('ThemeProvider', () => {
,
</ThemeProvider>,
);
- }).toErrorDev([
- 'Material-UI: You should return an object from your theme function',
- // strict mode renders twice
- 'Material-UI: You should return an object from your theme function',
- ]);
+ }).toErrorDev(['Material-UI: You should return an object from your theme function']);
});
});
});
diff --git a/packages/material-ui-styles/src/makeStyles/makeStyles.test.js b/packages/material-ui-styles/src/makeStyles/makeStyles.test.js
index cce608f6b..19cab2d18 100644
--- a/packages/material-ui-styles/src/makeStyles/makeStyles.test.js
+++ b/packages/material-ui-styles/src/makeStyles/makeStyles.test.js
@@ -213,7 +213,7 @@ describe('makeStyles', () => {
expect(sheetsRegistry.registry[0].classes).to.deep.equal({ root: 'makeStyles-root-2' });
wrapper.unmount();
- expect(sheetsRegistry.registry.length).to.equal(0);
+ expect(sheetsRegistry.registry.length).to.equal(1);
});
it('should work when depending on a theme', () => {
diff --git a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
index f5c603b45..2f18cca5c 100644
--- a/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
+++ b/packages/material-ui/src/Breadcrumbs/Breadcrumbs.test.js
@@ -93,7 +93,6 @@ describe('<Breadcrumbs />', () => {
);
}).toErrorDev([
'Material-UI: You have provided an invalid combination of props to the Breadcrumbs.\nitemsAfterCollapse={2} + itemsBeforeCollapse={2} >= maxItems={3}',
- 'Material-UI: You have provided an invalid combination of props to the Breadcrumbs.\nitemsAfterCollapse={2} + itemsBeforeCollapse={2} >= maxItems={3}',
]);
expect(screen.getAllByRole('listitem', { hidden: false })).to.have.length(4);
expect(screen.getByRole('list')).to.have.text('first/second/third/fourth');
diff --git a/packages/material-ui/src/Tabs/Tabs.test.js b/packages/material-ui/src/Tabs/Tabs.test.js
index 733b29a97..37b52ab4d 100644
--- a/packages/material-ui/src/Tabs/Tabs.test.js
+++ b/packages/material-ui/src/Tabs/Tabs.test.js
@@ -85,9 +85,6 @@ describe('<Tabs />', () => {
expect(() => {
render(<Tabs value={0} centered variant="scrollable" />);
}).toErrorDev([
- 'Material-UI: You can not use the `centered={true}` and `variant="scrollable"`',
- // StrictMode renders twice
- 'Material-UI: You can not use the `centered={true}` and `variant="scrollable"`',
'Material-UI: You can not use the `centered={true}` and `variant="scrollable"`',
'Material-UI: You can not use the `centered={true}` and `variant="scrollable"`',
]);
diff --git a/packages/material-ui/src/TextareaAutosize/TextareaAutosize.test.js b/packages/material-ui/src/TextareaAutosize/TextareaAutosize.test.js
index e22016776..03db8933d 100644
--- a/packages/material-ui/src/TextareaAutosize/TextareaAutosize.test.js
+++ b/packages/material-ui/src/TextareaAutosize/TextareaAutosize.test.js
@@ -253,12 +253,7 @@ describe('<TextareaAutosize />', () => {
expect(() => {
forceUpdate();
- }).toErrorDev([
- 'Material-UI: Too many re-renders.',
- // strict mode renders twice
- 'Material-UI: Too many re-renders.',
- 'Material-UI: Too many re-renders.',
- ]);
+ }).toErrorDev(['Material-UI: Too many re-renders.']);
});
});
});
diff --git a/packages/material-ui/src/Unstable_TrapFocus/Unstable_TrapFocus.js b/packages/material-ui/src/Unstable_TrapFocus/Unstable_TrapFocus.js
index 97fac726d..bd6b758db 100644
--- a/packages/material-ui/src/Unstable_TrapFocus/Unstable_TrapFocus.js
+++ b/packages/material-ui/src/Unstable_TrapFocus/Unstable_TrapFocus.js
@@ -163,7 +163,13 @@ function Unstable_TrapFocus(props) {
// in nodeToRestore.current being null.
// Not all elements in IE 11 have a focus method.
// Once IE 11 support is dropped the focus() call can be unconditional.
- if (nodeToRestore.current && nodeToRestore.current.focus) {
+ if (
+ nodeToRestore.current &&
+ nodeToRestore.current.focus &&
+ // TODO: Can be removed after https://github.com/jsdom/jsdom/pull/3005 is released.
+ // We technically only want a WeakRef to nodeToRestore anyway.
+ nodeToRestore.current.isConnected
+ ) {
nodeToRestore.current.focus();
}
diff --git a/packages/material-ui/src/internal/SwitchBase.test.js b/packages/material-ui/src/internal/SwitchBase.test.js
index 27b143abf..7c321b14a 100644
--- a/packages/material-ui/src/internal/SwitchBase.test.js
+++ b/packages/material-ui/src/internal/SwitchBase.test.js
@@ -360,7 +360,7 @@ describe('<SwitchBase />', () => {
expect(() => {
setProps({ checked: true });
}).toErrorDev([
- 'Warning: A component is changing an uncontrolled input of type checkbox to be controlled.',
+ 'Warning: A component is changing an uncontrolled input to be controlled.',
'Material-UI: A component is changing the uncontrolled checked state of SwitchBase to be controlled.',
]);
});
@@ -380,7 +380,7 @@ describe('<SwitchBase />', () => {
expect(() => {
setProps({ checked: undefined });
}).toErrorDev([
- 'Warning: A component is changing a controlled input of type checkbox to be uncontrolled.',
+ 'Warning: A component is changing a controlled input to be uncontrolled',
'Material-UI: A component is changing the controlled checked state of SwitchBase to be uncontrolled.',
]);
});
diff --git a/packages/material-ui/src/useMediaQuery/useMediaQuery.test.js b/packages/material-ui/src/useMediaQuery/useMediaQuery.test.js
index e5733f826..61333a172 100644
--- a/packages/material-ui/src/useMediaQuery/useMediaQuery.test.js
+++ b/packages/material-ui/src/useMediaQuery/useMediaQuery.test.js
@@ -276,11 +276,7 @@ describe('useMediaQuery', () => {
expect(() => {
render(<MyComponent />);
- }).toErrorDev([
- 'Material-UI: The `query` argument provided is invalid',
- // logs warning twice in StrictMode
- 'Material-UI: The `query` argument provided is invalid',
- ]);
+ }).toErrorDev(['Material-UI: The `query` argument provided is invalid']);
});
});
});
diff --git a/test/utils/createClientRender.js b/test/utils/createClientRender.js
index 2b6184ff9..cc38b14ab 100644
--- a/test/utils/createClientRender.js
+++ b/test/utils/createClientRender.js
@@ -87,6 +87,14 @@ function clientRender(element, options = {}) {
return result;
};
+ // TODO: Remove once we switch to `@testing-library/react@10.4.7`
+ const testingLibraryUnmount = result.unmount;
+ result.unmount = function unmountActing() {
+ act(() => {
+ testingLibraryUnmount();
+ });
+ };
+
return result;
}