@mui/internal-test-utils 2.0.15 → 2.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/{src/chai.types.ts → chai.types.d.ts} +7 -40
  2. package/chai.types.js +5 -0
  3. package/chaiPlugin.d.ts +4 -0
  4. package/chaiPlugin.js +287 -0
  5. package/{build/components.d.ts → components.d.ts} +18 -19
  6. package/components.js +64 -0
  7. package/createDOM.d.ts +2 -0
  8. package/{src/createDOM.js → createDOM.js} +17 -35
  9. package/createDescribe.d.ts +7 -0
  10. package/createDescribe.js +26 -0
  11. package/createRenderer.d.ts +214 -0
  12. package/createRenderer.js +428 -0
  13. package/createRenderer.test.d.ts +1 -0
  14. package/describeConformance.d.ts +200 -0
  15. package/describeConformance.js +1038 -0
  16. package/env.d.ts +1 -0
  17. package/env.js +11 -0
  18. package/esm/chai.types.d.ts +74 -0
  19. package/esm/chai.types.js +3 -0
  20. package/esm/chaiPlugin.d.ts +4 -0
  21. package/esm/chaiPlugin.js +281 -0
  22. package/esm/components.d.ts +35 -0
  23. package/esm/components.js +56 -0
  24. package/esm/createDOM.d.ts +2 -0
  25. package/esm/createDOM.js +47 -0
  26. package/esm/createDescribe.d.ts +7 -0
  27. package/esm/createDescribe.js +19 -0
  28. package/esm/createRenderer.d.ts +214 -0
  29. package/esm/createRenderer.js +390 -0
  30. package/esm/createRenderer.test.d.ts +1 -0
  31. package/esm/describeConformance.d.ts +200 -0
  32. package/esm/describeConformance.js +1024 -0
  33. package/esm/env.d.ts +1 -0
  34. package/esm/env.js +5 -0
  35. package/{build → esm}/fireDiscreteEvent.d.ts +1 -2
  36. package/{src/fireDiscreteEvent.ts → esm/fireDiscreteEvent.js} +10 -18
  37. package/esm/flushMicrotasks.d.ts +1 -0
  38. package/{src/flushMicrotasks.ts → esm/flushMicrotasks.js} +2 -3
  39. package/{build → esm}/focusVisible.d.ts +1 -2
  40. package/{src/focusVisible.ts → esm/focusVisible.js} +10 -9
  41. package/esm/index.d.ts +18 -0
  42. package/esm/index.js +27 -0
  43. package/esm/init.d.ts +1 -0
  44. package/{src → esm}/init.js +4 -2
  45. package/esm/initMatchers.d.ts +1 -0
  46. package/esm/initMatchers.js +6 -0
  47. package/esm/initMatchers.test.d.ts +1 -0
  48. package/esm/initPlaywrightMatchers.d.ts +24 -0
  49. package/esm/initPlaywrightMatchers.js +40 -0
  50. package/esm/package.json +1 -0
  51. package/esm/reactMajor.d.ts +2 -0
  52. package/esm/reactMajor.js +2 -0
  53. package/esm/setup.d.ts +1 -0
  54. package/{src → esm}/setup.js +2 -4
  55. package/esm/setupVitest.d.ts +1 -0
  56. package/esm/setupVitest.js +28 -0
  57. package/esm/setupVitestBrowser.d.ts +1 -0
  58. package/esm/setupVitestBrowser.js +30 -0
  59. package/fireDiscreteEvent.d.ts +6 -0
  60. package/fireDiscreteEvent.js +79 -0
  61. package/flushMicrotasks.d.ts +1 -0
  62. package/flushMicrotasks.js +10 -0
  63. package/focusVisible.d.ts +7 -0
  64. package/focusVisible.js +44 -0
  65. package/index.d.ts +18 -0
  66. package/index.js +139 -0
  67. package/init.d.ts +1 -0
  68. package/init.js +15 -0
  69. package/initMatchers.d.ts +1 -0
  70. package/initMatchers.js +10 -0
  71. package/initMatchers.test.d.ts +1 -0
  72. package/initPlaywrightMatchers.d.ts +24 -0
  73. package/initPlaywrightMatchers.js +42 -0
  74. package/package.json +89 -46
  75. package/reactMajor.d.ts +2 -0
  76. package/reactMajor.js +9 -0
  77. package/setup.d.ts +1 -0
  78. package/setup.js +10 -0
  79. package/setupVitest.d.ts +1 -0
  80. package/setupVitest.js +32 -0
  81. package/setupVitestBrowser.d.ts +1 -0
  82. package/setupVitestBrowser.js +34 -0
  83. package/build/.tsbuildinfo +0 -1
  84. package/build/KarmaReporterReactProfiler.d.ts +0 -51
  85. package/build/KarmaReporterReactProfiler.d.ts.map +0 -1
  86. package/build/KarmaReporterReactProfiler.js +0 -66
  87. package/build/KarmaReporterReactProfiler.js.map +0 -1
  88. package/build/chai.types.d.ts +0 -75
  89. package/build/chai.types.d.ts.map +0 -1
  90. package/build/chai.types.js +0 -3
  91. package/build/chai.types.js.map +0 -1
  92. package/build/chaiPlugin.d.ts +0 -5
  93. package/build/chaiPlugin.d.ts.map +0 -1
  94. package/build/chaiPlugin.js +0 -416
  95. package/build/chaiPlugin.js.map +0 -1
  96. package/build/components.d.ts.map +0 -1
  97. package/build/components.js +0 -88
  98. package/build/components.js.map +0 -1
  99. package/build/createDOM.d.ts +0 -3
  100. package/build/createDOM.d.ts.map +0 -1
  101. package/build/createDOM.js +0 -60
  102. package/build/createDOM.js.map +0 -1
  103. package/build/createDescribe.d.ts +0 -8
  104. package/build/createDescribe.d.ts.map +0 -1
  105. package/build/createDescribe.js +0 -22
  106. package/build/createDescribe.js.map +0 -1
  107. package/build/createRenderer.d.ts +0 -215
  108. package/build/createRenderer.d.ts.map +0 -1
  109. package/build/createRenderer.js +0 -564
  110. package/build/createRenderer.js.map +0 -1
  111. package/build/createRenderer.test.d.ts +0 -2
  112. package/build/createRenderer.test.d.ts.map +0 -1
  113. package/build/createRenderer.test.js +0 -58
  114. package/build/createRenderer.test.js.map +0 -1
  115. package/build/describeConformance.d.ts +0 -201
  116. package/build/describeConformance.d.ts.map +0 -1
  117. package/build/describeConformance.js +0 -859
  118. package/build/describeConformance.js.map +0 -1
  119. package/build/describeSkipIf.d.ts +0 -4
  120. package/build/describeSkipIf.d.ts.map +0 -1
  121. package/build/describeSkipIf.js +0 -10
  122. package/build/describeSkipIf.js.map +0 -1
  123. package/build/fireDiscreteEvent.d.ts.map +0 -1
  124. package/build/fireDiscreteEvent.js +0 -77
  125. package/build/fireDiscreteEvent.js.map +0 -1
  126. package/build/flushMicrotasks.d.ts +0 -2
  127. package/build/flushMicrotasks.d.ts.map +0 -1
  128. package/build/flushMicrotasks.js +0 -8
  129. package/build/flushMicrotasks.js.map +0 -1
  130. package/build/focusVisible.d.ts.map +0 -1
  131. package/build/focusVisible.js +0 -38
  132. package/build/focusVisible.js.map +0 -1
  133. package/build/index.d.ts +0 -18
  134. package/build/index.d.ts.map +0 -1
  135. package/build/index.js +0 -68
  136. package/build/index.js.map +0 -1
  137. package/build/init.d.ts +0 -2
  138. package/build/init.d.ts.map +0 -1
  139. package/build/init.js +0 -46
  140. package/build/init.js.map +0 -1
  141. package/build/initMatchers.d.ts +0 -2
  142. package/build/initMatchers.d.ts.map +0 -1
  143. package/build/initMatchers.js +0 -45
  144. package/build/initMatchers.js.map +0 -1
  145. package/build/initMatchers.test.d.ts +0 -2
  146. package/build/initMatchers.test.d.ts.map +0 -1
  147. package/build/initMatchers.test.js +0 -101
  148. package/build/initMatchers.test.js.map +0 -1
  149. package/build/initPlaywrightMatchers.d.ts +0 -25
  150. package/build/initPlaywrightMatchers.d.ts.map +0 -1
  151. package/build/initPlaywrightMatchers.js +0 -73
  152. package/build/initPlaywrightMatchers.js.map +0 -1
  153. package/build/mochaHooks.d.ts +0 -24
  154. package/build/mochaHooks.d.ts.map +0 -1
  155. package/build/mochaHooks.js +0 -165
  156. package/build/mochaHooks.js.map +0 -1
  157. package/build/mochaHooks.test.d.ts +0 -2
  158. package/build/mochaHooks.test.d.ts.map +0 -1
  159. package/build/mochaHooks.test.js +0 -128
  160. package/build/mochaHooks.test.js.map +0 -1
  161. package/build/reactMajor.d.ts +0 -3
  162. package/build/reactMajor.d.ts.map +0 -1
  163. package/build/reactMajor.js +0 -38
  164. package/build/reactMajor.js.map +0 -1
  165. package/build/setup.d.ts +0 -2
  166. package/build/setup.d.ts.map +0 -1
  167. package/build/setup.js +0 -10
  168. package/build/setup.js.map +0 -1
  169. package/build/setupBabel.d.ts +0 -2
  170. package/build/setupBabel.d.ts.map +0 -1
  171. package/build/setupBabel.js +0 -5
  172. package/build/setupBabel.js.map +0 -1
  173. package/build/setupBabelPlaywright.d.ts +0 -2
  174. package/build/setupBabelPlaywright.d.ts.map +0 -1
  175. package/build/setupBabelPlaywright.js +0 -14
  176. package/build/setupBabelPlaywright.js.map +0 -1
  177. package/build/setupJSDOM.d.ts +0 -7
  178. package/build/setupJSDOM.d.ts.map +0 -1
  179. package/build/setupJSDOM.js +0 -17
  180. package/build/setupJSDOM.js.map +0 -1
  181. package/build/setupKarma.d.ts +0 -2
  182. package/build/setupKarma.d.ts.map +0 -1
  183. package/build/setupKarma.js +0 -56
  184. package/build/setupKarma.js.map +0 -1
  185. package/build/setupVitest.d.ts +0 -2
  186. package/build/setupVitest.d.ts.map +0 -1
  187. package/build/setupVitest.js +0 -131
  188. package/build/setupVitest.js.map +0 -1
  189. package/src/KarmaReporterReactProfiler.js +0 -82
  190. package/src/chai-augmentation.d.ts +0 -8
  191. package/src/chaiPlugin.ts +0 -515
  192. package/src/components.tsx +0 -61
  193. package/src/createDOM.d.ts +0 -9
  194. package/src/createDescribe.ts +0 -31
  195. package/src/createRenderer.test.js +0 -31
  196. package/src/createRenderer.tsx +0 -808
  197. package/src/describeConformance.tsx +0 -1257
  198. package/src/describeSkipIf.tsx +0 -11
  199. package/src/index.ts +0 -25
  200. package/src/initMatchers.test.js +0 -124
  201. package/src/initMatchers.ts +0 -7
  202. package/src/initPlaywrightMatchers.ts +0 -101
  203. package/src/mochaHooks.js +0 -200
  204. package/src/mochaHooks.test.js +0 -116
  205. package/src/reactMajor.ts +0 -3
  206. package/src/setupBabel.js +0 -3
  207. package/src/setupBabelPlaywright.js +0 -13
  208. package/src/setupJSDOM.js +0 -20
  209. package/src/setupKarma.js +0 -65
  210. package/src/setupVitest.ts +0 -117
  211. package/tsconfig.build.json +0 -16
  212. package/tsconfig.json +0 -17
@@ -0,0 +1,1038 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ exports.describeRef = describeRef;
10
+ exports.randomStringValue = randomStringValue;
11
+ exports.testClassName = testClassName;
12
+ exports.testComponentProp = testComponentProp;
13
+ exports.testPropsSpread = testPropsSpread;
14
+ exports.testRootClass = testRootClass;
15
+ var _chai = require("chai");
16
+ var React = _interopRequireWildcard(require("react"));
17
+ var _vitest = require("vitest");
18
+ var _createDescribe = _interopRequireDefault(require("./createDescribe"));
19
+ var _jsxRuntime = require("react/jsx-runtime");
20
+ function capitalize(string) {
21
+ return string.charAt(0).toUpperCase() + string.slice(1);
22
+ }
23
+ /**
24
+ * Glossary
25
+ * - root component:
26
+ * - renders the outermost host component
27
+ * - has the `root` class if the component has one
28
+ * - excess props are spread to this component
29
+ * - has the type of `inheritComponent`
30
+ */
31
+
32
+ function randomStringValue() {
33
+ return `s${Math.random().toString(36).slice(2)}`;
34
+ }
35
+ function throwMissingPropError(field) {
36
+ throw new Error(`missing "${field}" in options
37
+
38
+ > describeConformance(element, () => options)
39
+ `);
40
+ }
41
+
42
+ /**
43
+ * MUI components have a `className` prop. The `className` is applied to
44
+ * the root component.
45
+ */
46
+ function testClassName(element, getOptions) {
47
+ (0, _vitest.it)('applies the className to the root component', async () => {
48
+ const {
49
+ render
50
+ } = getOptions();
51
+ if (!render) {
52
+ throwMissingPropError('render');
53
+ }
54
+ const className = randomStringValue();
55
+ const testId = randomStringValue();
56
+ const {
57
+ getByTestId
58
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
59
+ className,
60
+ 'data-testid': testId
61
+ }));
62
+ (0, _chai.expect)(getByTestId(testId)).to.have.class(className);
63
+ });
64
+ }
65
+
66
+ /**
67
+ * MUI components have a `component` prop that allows rendering a different
68
+ * Component from @inheritComponent
69
+ */
70
+ function testComponentProp(element, getOptions) {
71
+ (0, _vitest.describe)('prop: component', () => {
72
+ (0, _vitest.it)('can render another root component with the `component` prop', async () => {
73
+ const {
74
+ render,
75
+ testComponentPropWith: component = 'em'
76
+ } = getOptions();
77
+ if (!render) {
78
+ throwMissingPropError('render');
79
+ }
80
+ const testId = randomStringValue();
81
+ if (typeof component === 'string') {
82
+ const {
83
+ getByTestId
84
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
85
+ component,
86
+ 'data-testid': testId
87
+ }));
88
+ (0, _chai.expect)(getByTestId(testId)).not.to.equal(null);
89
+ (0, _chai.expect)(getByTestId(testId).nodeName.toLowerCase()).to.eq(component);
90
+ } else {
91
+ const componentWithTestId = props => /*#__PURE__*/React.createElement(component, {
92
+ ...props,
93
+ 'data-testid': testId
94
+ });
95
+ const {
96
+ getByTestId
97
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
98
+ component: componentWithTestId
99
+ }));
100
+ (0, _chai.expect)(getByTestId(testId)).not.to.equal(null);
101
+ }
102
+ });
103
+ });
104
+ }
105
+
106
+ /**
107
+ * MUI components spread additional props to its root.
108
+ */
109
+ function testPropsSpread(element, getOptions) {
110
+ (0, _vitest.it)(`spreads props to the root component`, async () => {
111
+ // type def in ConformanceOptions
112
+ const {
113
+ render
114
+ } = getOptions();
115
+ if (!render) {
116
+ throwMissingPropError('render');
117
+ }
118
+ const testProp = 'data-test-props-spread';
119
+ const value = randomStringValue();
120
+ const testId = randomStringValue();
121
+ const {
122
+ getByTestId
123
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
124
+ [testProp]: value,
125
+ 'data-testid': testId
126
+ }));
127
+ (0, _chai.expect)(getByTestId(testId)).to.have.attribute(testProp, value);
128
+ });
129
+ }
130
+
131
+ /**
132
+ * Tests that the `ref` of a component will return the correct instance
133
+ *
134
+ * This is determined by a given constructor i.e. a React.Component or HTMLElement for
135
+ * components that forward their ref and attach it to a host component.
136
+ */
137
+ function describeRef(element, getOptions) {
138
+ (0, _vitest.describe)('ref', () => {
139
+ (0, _vitest.it)(`attaches the ref`, async () => {
140
+ // type def in ConformanceOptions
141
+ const {
142
+ render,
143
+ refInstanceof
144
+ } = getOptions();
145
+ if (!render) {
146
+ throwMissingPropError('render');
147
+ }
148
+ const ref = /*#__PURE__*/React.createRef();
149
+ await render(/*#__PURE__*/React.cloneElement(element, {
150
+ ref
151
+ }));
152
+ (0, _chai.expect)(ref.current).to.be.instanceof(refInstanceof);
153
+ });
154
+ });
155
+ }
156
+
157
+ /**
158
+ * Tests that the root component has the root class
159
+ */
160
+ function testRootClass(element, getOptions) {
161
+ (0, _vitest.it)('applies the root class to the root component if it has this class', async () => {
162
+ const {
163
+ classes,
164
+ render,
165
+ skip
166
+ } = getOptions();
167
+ if (classes.root == null) {
168
+ return;
169
+ }
170
+ const className = randomStringValue();
171
+ const classesRootClassname = randomStringValue();
172
+ const {
173
+ container
174
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
175
+ className,
176
+ classes: {
177
+ ...classes,
178
+ root: `${classes.root} ${classesRootClassname}`
179
+ }
180
+ }));
181
+
182
+ // we established that the root component renders the outermost host previously. We immediately
183
+ // jump to the host component because some components pass the `root` class
184
+ // to the `classes` prop of the root component.
185
+ // https://github.com/mui/material-ui/blob/f9896bcd129a1209153106296b3d2487547ba205/packages/material-ui/src/OutlinedInput/OutlinedInput.js#L101
186
+ (0, _chai.expect)(container.firstChild).to.have.class(className);
187
+ (0, _chai.expect)(container.firstChild).to.have.class(classes.root);
188
+ (0, _chai.expect)(document.querySelectorAll(`.${classes.root}`).length).to.equal(1);
189
+
190
+ // classes test only for @mui/material
191
+ if (!skip || !skip.includes('classesRoot')) {
192
+ // Test that classes prop works
193
+ (0, _chai.expect)(container.firstChild).to.have.class(classesRootClassname);
194
+
195
+ // Test that `classes` does not spread to DOM
196
+ (0, _chai.expect)(document.querySelectorAll('[classes]').length).to.equal(0);
197
+ }
198
+ });
199
+ }
200
+ function forEachSlot(slots, callback) {
201
+ if (!slots) {
202
+ return;
203
+ }
204
+ const slotNames = Object.keys(slots);
205
+ slotNames.forEach(slotName => {
206
+ const slot = slots[slotName];
207
+ callback(slotName, slot);
208
+ });
209
+ }
210
+ function testSlotsProp(element, getOptions) {
211
+ const {
212
+ render,
213
+ slots,
214
+ testLegacyComponentsProp
215
+ } = getOptions();
216
+ const CustomComponent = /*#__PURE__*/React.forwardRef(({
217
+ className,
218
+ children
219
+ }, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
220
+ className: className,
221
+ ref: ref,
222
+ "data-testid": "custom",
223
+ children: children
224
+ }));
225
+ forEachSlot(slots, (slotName, slotOptions) => {
226
+ (0, _vitest.it)(`allows overriding the ${slotName} slot with a component using the slots.${slotName} prop`, async () => {
227
+ if (!render) {
228
+ throwMissingPropError('render');
229
+ }
230
+ const slotComponent = slotOptions.testWithComponent ?? CustomComponent;
231
+ const components = {
232
+ [slotName]: slotComponent
233
+ };
234
+ const {
235
+ queryByTestId
236
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
237
+ slots: components
238
+ }));
239
+ const renderedElement = queryByTestId('custom');
240
+ (0, _chai.expect)(renderedElement).not.to.equal(null);
241
+ if (slotOptions.expectedClassName) {
242
+ (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
243
+ }
244
+ });
245
+ if (slotOptions.testWithElement !== null) {
246
+ (0, _vitest.it)(`allows overriding the ${slotName} slot with an element using the slots.${slotName} prop`, async () => {
247
+ if (!render) {
248
+ throwMissingPropError('render');
249
+ }
250
+ const slotElement = slotOptions.testWithElement ?? 'i';
251
+ const components = {
252
+ [slotName]: slotElement
253
+ };
254
+ const slotProps = {
255
+ [slotName]: {
256
+ 'data-testid': 'customized'
257
+ }
258
+ };
259
+ const {
260
+ queryByTestId
261
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
262
+ slots: components,
263
+ slotProps
264
+ }));
265
+ const renderedElement = queryByTestId('customized');
266
+ (0, _chai.expect)(renderedElement).not.to.equal(null);
267
+ if (typeof slotElement === 'string') {
268
+ (0, _chai.expect)(renderedElement.nodeName.toLowerCase()).to.equal(slotElement);
269
+ }
270
+ if (slotOptions.expectedClassName) {
271
+ (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
272
+ }
273
+ });
274
+ }
275
+
276
+ // For testing Material UI components v5, and v6. Likely to be removed in a future major release.
277
+ if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
278
+ (0, _vitest.it)(`allows overriding the ${slotName} slot with a component using the components.${capitalize(slotName)} prop`, async () => {
279
+ if (!render) {
280
+ throwMissingPropError('render');
281
+ }
282
+ const slotComponent = slotOptions.testWithComponent ?? CustomComponent;
283
+ const components = {
284
+ [capitalize(slotName)]: slotComponent
285
+ };
286
+ const {
287
+ queryByTestId
288
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
289
+ components
290
+ }));
291
+ const renderedElement = queryByTestId('custom');
292
+ (0, _chai.expect)(renderedElement).not.to.equal(null);
293
+ if (slotOptions.expectedClassName) {
294
+ (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
295
+ }
296
+ });
297
+ (0, _vitest.it)(`prioritizes the 'slots.${slotName}' over components.${capitalize(slotName)} if both are defined`, async () => {
298
+ if (!render) {
299
+ throwMissingPropError('render');
300
+ }
301
+ const ComponentForComponentsProp = /*#__PURE__*/React.forwardRef(({
302
+ children
303
+ }, ref) => {
304
+ const SlotComponent = slotOptions.testWithComponent ?? 'div';
305
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotComponent, {
306
+ ref: ref,
307
+ "data-testid": "from-components",
308
+ children: children
309
+ });
310
+ });
311
+ const ComponentForSlotsProp = /*#__PURE__*/React.forwardRef(({
312
+ children
313
+ }, ref) => {
314
+ const SlotComponent = slotOptions.testWithComponent ?? 'div';
315
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotComponent, {
316
+ ref: ref,
317
+ "data-testid": "from-slots",
318
+ children: children
319
+ });
320
+ });
321
+ const components = {
322
+ [capitalize(slotName)]: ComponentForComponentsProp
323
+ };
324
+ const slotOverrides = {
325
+ [slotName]: ComponentForSlotsProp
326
+ };
327
+ const {
328
+ queryByTestId
329
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
330
+ components,
331
+ slots: slotOverrides
332
+ }));
333
+ (0, _chai.expect)(queryByTestId('from-slots')).not.to.equal(null);
334
+ (0, _chai.expect)(queryByTestId('from-components')).to.equal(null);
335
+ });
336
+ if (slotOptions.testWithElement !== null) {
337
+ (0, _vitest.it)(`allows overriding the ${slotName} slot with an element using the components.${capitalize(slotName)} prop`, async () => {
338
+ if (!render) {
339
+ throwMissingPropError('render');
340
+ }
341
+ const slotElement = slotOptions.testWithElement ?? 'i';
342
+ const components = {
343
+ [capitalize(slotName)]: slotElement
344
+ };
345
+ const componentsProps = {
346
+ [slotName]: {
347
+ 'data-testid': 'customized'
348
+ }
349
+ };
350
+ const {
351
+ queryByTestId
352
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
353
+ components,
354
+ componentsProps
355
+ }));
356
+ const renderedElement = queryByTestId('customized');
357
+ (0, _chai.expect)(renderedElement).not.to.equal(null);
358
+ if (typeof slotElement === 'string') {
359
+ (0, _chai.expect)(renderedElement.nodeName.toLowerCase()).to.equal(slotElement);
360
+ }
361
+ if (slotOptions.expectedClassName) {
362
+ (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
363
+ }
364
+ });
365
+ }
366
+ }
367
+ });
368
+ }
369
+ function testSlotPropsProp(element, getOptions) {
370
+ const {
371
+ render,
372
+ slots,
373
+ testLegacyComponentsProp
374
+ } = getOptions();
375
+ if (!render) {
376
+ throwMissingPropError('render');
377
+ }
378
+ forEachSlot(slots, (slotName, slotOptions) => {
379
+ (0, _vitest.it)(`sets custom properties on the ${slotName} slot's element with the slotProps.${slotName} prop`, async () => {
380
+ const slotProps = {
381
+ [slotName]: {
382
+ 'data-testid': 'custom'
383
+ }
384
+ };
385
+ const {
386
+ queryByTestId
387
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
388
+ slotProps
389
+ }));
390
+ const slotComponent = queryByTestId('custom');
391
+ (0, _chai.expect)(slotComponent).not.to.equal(null);
392
+ if (slotOptions.expectedClassName) {
393
+ (0, _chai.expect)(slotComponent).to.have.class(slotOptions.expectedClassName);
394
+ }
395
+ });
396
+ if (slotOptions.expectedClassName) {
397
+ (0, _vitest.it)(`merges the class names provided in slotsProps.${slotName} with the built-in ones`, async () => {
398
+ const slotProps = {
399
+ [slotName]: {
400
+ 'data-testid': 'custom',
401
+ className: randomStringValue()
402
+ }
403
+ };
404
+ const {
405
+ getByTestId
406
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
407
+ slotProps
408
+ }));
409
+ (0, _chai.expect)(getByTestId('custom')).to.have.class(slotOptions.expectedClassName);
410
+ (0, _chai.expect)(getByTestId('custom')).to.have.class(slotProps[slotName].className);
411
+ });
412
+ }
413
+ if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
414
+ (0, _vitest.it)(`sets custom properties on the ${slotName} slot's element with the componentsProps.${slotName} prop`, async () => {
415
+ const componentsProps = {
416
+ [slotName]: {
417
+ 'data-testid': 'custom'
418
+ }
419
+ };
420
+ const {
421
+ queryByTestId
422
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
423
+ componentsProps
424
+ }));
425
+ const slotComponent = queryByTestId('custom');
426
+ (0, _chai.expect)(slotComponent).not.to.equal(null);
427
+ if (slotOptions.expectedClassName) {
428
+ (0, _chai.expect)(slotComponent).to.have.class(slotOptions.expectedClassName);
429
+ }
430
+ });
431
+ (0, _vitest.it)(`prioritizes the 'slotProps.${slotName}' over componentsProps.${slotName} if both are defined`, async () => {
432
+ const componentsProps = {
433
+ [slotName]: {
434
+ 'data-testid': 'custom',
435
+ 'data-from-components-props': 'true'
436
+ }
437
+ };
438
+ const slotProps = {
439
+ [slotName]: {
440
+ 'data-testid': 'custom',
441
+ 'data-from-slot-props': 'true'
442
+ }
443
+ };
444
+ const {
445
+ queryByTestId
446
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
447
+ componentsProps,
448
+ slotProps
449
+ }));
450
+ const slotComponent = queryByTestId('custom');
451
+ (0, _chai.expect)(slotComponent).to.have.attribute('data-from-slot-props', 'true');
452
+ (0, _chai.expect)(slotComponent).not.to.have.attribute('data-from-components-props');
453
+ });
454
+ }
455
+ });
456
+ }
457
+ function testSlotPropsCallback(element, getOptions) {
458
+ const {
459
+ render,
460
+ slots
461
+ } = getOptions();
462
+ if (!render) {
463
+ throwMissingPropError('render');
464
+ }
465
+ forEachSlot(slots, slotName => {
466
+ (0, _vitest.it)(`sets custom properties on the ${slotName} slot's element with the slotProps.${slotName} callback`, async () => {
467
+ const slotProps = {
468
+ [slotName]: () => ({
469
+ 'data-testid': 'custom'
470
+ })
471
+ };
472
+ const {
473
+ queryByTestId
474
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
475
+ slotProps,
476
+ className: 'custom'
477
+ }));
478
+ const slotComponent = queryByTestId('custom');
479
+ (0, _chai.expect)(slotComponent).not.to.equal(null);
480
+ });
481
+ });
482
+ }
483
+ function testSlotPropsCallbackWithPropsAsOwnerState(element, getOptions) {
484
+ const {
485
+ render,
486
+ slots
487
+ } = getOptions();
488
+ if (!render) {
489
+ throwMissingPropError('render');
490
+ }
491
+ forEachSlot(slots, slotName => {
492
+ (0, _vitest.it)(`sets custom properties on the ${slotName} slot's element with the slotProps.${slotName} callback using the ownerState`, async () => {
493
+ const slotProps = {
494
+ [slotName]: ownerState => ({
495
+ 'data-testid': ownerState.className
496
+ })
497
+ };
498
+ const {
499
+ queryByTestId
500
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
501
+ slotProps,
502
+ className: 'custom'
503
+ }));
504
+ const slotComponent = queryByTestId('custom', {
505
+ exact: false
506
+ });
507
+ (0, _chai.expect)(slotComponent).not.to.equal(null);
508
+ });
509
+ });
510
+ }
511
+
512
+ /**
513
+ * MUI components have a `components` prop that allows rendering a different
514
+ * Components from @inheritComponent
515
+ */
516
+ function testComponentsProp(element, getOptions) {
517
+ (0, _vitest.describe)('prop components:', () => {
518
+ (0, _vitest.it)('can render another root component with the `components` prop', async () => {
519
+ const {
520
+ render,
521
+ testComponentsRootPropWith: component = 'em'
522
+ } = getOptions();
523
+ if (!render) {
524
+ throwMissingPropError('render');
525
+ }
526
+ const testId = randomStringValue();
527
+ const {
528
+ getByTestId
529
+ } = await render(/*#__PURE__*/React.cloneElement(element, {
530
+ components: {
531
+ Root: component
532
+ },
533
+ 'data-testid': testId
534
+ }));
535
+ (0, _chai.expect)(getByTestId(testId)).not.to.equal(null);
536
+ (0, _chai.expect)(getByTestId(testId).nodeName.toLowerCase()).to.eq(component);
537
+ });
538
+ });
539
+ }
540
+
541
+ /**
542
+ * MUI theme has a components section that allows specifying default props.
543
+ * Components from @inheritComponent
544
+ */
545
+ function testThemeDefaultProps(element, getOptions) {
546
+ (0, _vitest.describe)('theme default components:', () => {
547
+ (0, _vitest.it)("respect theme's defaultProps", async () => {
548
+ const testProp = 'data-id';
549
+ const {
550
+ muiName,
551
+ render,
552
+ ThemeProvider,
553
+ createTheme
554
+ } = getOptions();
555
+ if (!muiName) {
556
+ throwMissingPropError('muiName');
557
+ }
558
+ if (!render) {
559
+ throwMissingPropError('render');
560
+ }
561
+ if (!ThemeProvider) {
562
+ throwMissingPropError('ThemeProvider');
563
+ }
564
+ if (!createTheme) {
565
+ throwMissingPropError('createTheme');
566
+ }
567
+ const theme = createTheme({
568
+ components: {
569
+ [muiName]: {
570
+ defaultProps: {
571
+ [testProp]: 'testProp'
572
+ }
573
+ }
574
+ }
575
+ });
576
+ const {
577
+ container
578
+ } = await render(/*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
579
+ theme: theme,
580
+ children: element
581
+ }));
582
+ (0, _chai.expect)(container.firstChild).to.have.attribute(testProp, 'testProp');
583
+ });
584
+ });
585
+ (0, _vitest.describe)('default props provider:', () => {
586
+ const {
587
+ muiName,
588
+ render,
589
+ DefaultPropsProvider
590
+ } = getOptions();
591
+ _vitest.it.skipIf(!DefaultPropsProvider)('respect custom default props', async function test() {
592
+ const testProp = 'data-id';
593
+ if (!muiName) {
594
+ throwMissingPropError('muiName');
595
+ }
596
+ if (!render) {
597
+ throwMissingPropError('render');
598
+ }
599
+ const {
600
+ container
601
+ } = await render(
602
+ /*#__PURE__*/
603
+ // @ts-expect-error we skip it above.
604
+ (0, _jsxRuntime.jsx)(DefaultPropsProvider, {
605
+ value: {
606
+ [muiName]: {
607
+ defaultProps: {
608
+ [testProp]: 'testProp'
609
+ }
610
+ }
611
+ },
612
+ children: element
613
+ }));
614
+ (0, _chai.expect)(container.firstChild).to.have.attribute(testProp, 'testProp');
615
+ });
616
+ });
617
+ }
618
+
619
+ /**
620
+ * MUI theme has a components section that allows specifying style overrides.
621
+ * Components from @inheritComponent
622
+ */
623
+ function testThemeStyleOverrides(element, getOptions) {
624
+ (0, _vitest.describe)('theme style overrides:', () => {
625
+ _vitest.it.skipIf(window.navigator.userAgent.includes('jsdom'))("respect theme's styleOverrides custom state", async function test() {
626
+ const {
627
+ muiName,
628
+ testStateOverrides,
629
+ render,
630
+ ThemeProvider,
631
+ createTheme
632
+ } = getOptions();
633
+ if (!testStateOverrides) {
634
+ return;
635
+ }
636
+ if (!muiName) {
637
+ throwMissingPropError('muiName');
638
+ }
639
+ if (!render) {
640
+ throwMissingPropError('render');
641
+ }
642
+ if (!ThemeProvider) {
643
+ throwMissingPropError('ThemeProvider');
644
+ }
645
+ if (!createTheme) {
646
+ throwMissingPropError('createTheme');
647
+ }
648
+ const testStyle = {
649
+ marginTop: '13px'
650
+ };
651
+ const theme = createTheme({
652
+ components: {
653
+ [muiName]: {
654
+ styleOverrides: {
655
+ [testStateOverrides.styleKey]: testStyle
656
+ }
657
+ }
658
+ }
659
+ });
660
+ if (!testStateOverrides.prop) {
661
+ return;
662
+ }
663
+ const {
664
+ container
665
+ } = await render(/*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
666
+ theme: theme,
667
+ children: /*#__PURE__*/React.cloneElement(element, {
668
+ [testStateOverrides.prop]: testStateOverrides.value
669
+ })
670
+ }));
671
+ (0, _chai.expect)(container.firstChild).to.toHaveComputedStyle(testStyle);
672
+ });
673
+ _vitest.it.skipIf(window.navigator.userAgent.includes('jsdom'))("respect theme's styleOverrides slots", async function test() {
674
+ const {
675
+ muiName,
676
+ testDeepOverrides,
677
+ testRootOverrides = {
678
+ slotName: 'root'
679
+ },
680
+ render,
681
+ ThemeProvider,
682
+ createTheme
683
+ } = getOptions();
684
+ if (!ThemeProvider) {
685
+ throwMissingPropError('ThemeProvider');
686
+ }
687
+ if (!createTheme) {
688
+ throwMissingPropError('createTheme');
689
+ }
690
+ const testStyle = {
691
+ mixBlendMode: 'darken'
692
+ };
693
+ function resolveDeepOverrides(callback) {
694
+ if (!testDeepOverrides) {
695
+ return {};
696
+ }
697
+ const styles = {};
698
+ if (Array.isArray(testDeepOverrides)) {
699
+ testDeepOverrides.forEach(slot => {
700
+ callback(styles, slot);
701
+ });
702
+ } else {
703
+ callback(styles, testDeepOverrides);
704
+ }
705
+ return styles;
706
+ }
707
+ const theme = createTheme({
708
+ components: {
709
+ [muiName]: {
710
+ styleOverrides: {
711
+ [testRootOverrides.slotName]: {
712
+ ...testStyle,
713
+ ...resolveDeepOverrides((styles, slot) => {
714
+ styles[`& .${slot.slotClassName}`] = {
715
+ fontVariantCaps: 'all-petite-caps'
716
+ };
717
+ })
718
+ },
719
+ ...resolveDeepOverrides((styles, slot) => {
720
+ styles[slot.slotName] = {
721
+ mixBlendMode: 'darken'
722
+ };
723
+ })
724
+ }
725
+ }
726
+ }
727
+ });
728
+ const {
729
+ container,
730
+ setProps
731
+ } = await render(/*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
732
+ theme: theme,
733
+ children: element
734
+ }));
735
+ if (testRootOverrides.slotClassName) {
736
+ (0, _chai.expect)(document.querySelector(`.${testRootOverrides.slotClassName}`)).to.toHaveComputedStyle(testStyle);
737
+ } else {
738
+ (0, _chai.expect)(container.firstChild).to.toHaveComputedStyle(testStyle);
739
+ }
740
+ if (testDeepOverrides) {
741
+ (Array.isArray(testDeepOverrides) ? testDeepOverrides : [testDeepOverrides]).forEach(slot => {
742
+ (0, _chai.expect)(document.querySelector(`.${slot.slotClassName}`)).to.toHaveComputedStyle({
743
+ fontVariantCaps: 'all-petite-caps',
744
+ mixBlendMode: 'darken'
745
+ });
746
+ });
747
+ const themeWithoutRootOverrides = createTheme({
748
+ components: {
749
+ [muiName]: {
750
+ styleOverrides: {
751
+ ...resolveDeepOverrides((styles, slot) => {
752
+ styles[slot.slotName] = testStyle;
753
+ })
754
+ }
755
+ }
756
+ }
757
+ });
758
+ setProps({
759
+ theme: themeWithoutRootOverrides
760
+ });
761
+ (Array.isArray(testDeepOverrides) ? testDeepOverrides : [testDeepOverrides]).forEach(slot => {
762
+ (0, _chai.expect)(document.querySelector(`.${slot.slotClassName}`)).to.toHaveComputedStyle(testStyle);
763
+ });
764
+ }
765
+ });
766
+ _vitest.it.skipIf(window.navigator.userAgent.includes('jsdom'))('overrideStyles does not replace each other in slots', async function test() {
767
+ const {
768
+ muiName,
769
+ classes,
770
+ testStateOverrides,
771
+ render,
772
+ ThemeProvider,
773
+ createTheme
774
+ } = getOptions();
775
+ if (!ThemeProvider) {
776
+ throwMissingPropError('ThemeProvider');
777
+ }
778
+ if (!createTheme) {
779
+ throwMissingPropError('createTheme');
780
+ }
781
+ const classKeys = Object.keys(classes);
782
+
783
+ // only test the component that has `root` and other classKey
784
+ if (!testStateOverrides || !classKeys.includes('root') || classKeys.length === 1) {
785
+ return;
786
+ }
787
+
788
+ // `styleKey` in some tests is `foo` or `bar`, so need to check if it is a valid classKey.
789
+ const isStyleKeyExists = classKeys.includes(testStateOverrides.styleKey);
790
+ if (!isStyleKeyExists) {
791
+ return;
792
+ }
793
+ const theme = createTheme({
794
+ components: {
795
+ [muiName]: {
796
+ styleOverrides: {
797
+ root: {
798
+ [`&.${classes.root}`]: {
799
+ filter: 'blur(1px)',
800
+ mixBlendMode: 'darken'
801
+ }
802
+ },
803
+ ...(testStateOverrides && {
804
+ [testStateOverrides.styleKey]: {
805
+ [`&.${classes.root}`]: {
806
+ mixBlendMode: 'color'
807
+ }
808
+ }
809
+ })
810
+ }
811
+ }
812
+ }
813
+ });
814
+ if (!testStateOverrides.prop) {
815
+ return;
816
+ }
817
+ await render(/*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
818
+ theme: theme,
819
+ children: /*#__PURE__*/React.cloneElement(element, {
820
+ [testStateOverrides.prop]: testStateOverrides.value
821
+ })
822
+ }));
823
+ (0, _chai.expect)(document.querySelector(`.${classes.root}`)).toHaveComputedStyle({
824
+ filter: 'blur(1px)',
825
+ // still valid in root
826
+ mixBlendMode: 'color' // overridden by `styleKey`
827
+ });
828
+ });
829
+ });
830
+ }
831
+
832
+ /**
833
+ * MUI theme has a components section that allows specifying custom variants.
834
+ * Components from @inheritComponent
835
+ */
836
+ function testThemeVariants(element, getOptions) {
837
+ (0, _vitest.describe)('theme variants:', () => {
838
+ _vitest.it.skipIf(window.navigator.userAgent.includes('jsdom'))("respect theme's variants", async function test() {
839
+ const {
840
+ muiName,
841
+ testVariantProps,
842
+ render,
843
+ ThemeProvider,
844
+ createTheme
845
+ } = getOptions();
846
+ if (!testVariantProps) {
847
+ throw new Error('missing testVariantProps');
848
+ }
849
+ if (!muiName) {
850
+ throwMissingPropError('muiName');
851
+ }
852
+ if (!render) {
853
+ throwMissingPropError('render');
854
+ }
855
+ if (!ThemeProvider) {
856
+ throwMissingPropError('ThemeProvider');
857
+ }
858
+ if (!createTheme) {
859
+ throwMissingPropError('createTheme');
860
+ }
861
+ const testStyle = {
862
+ mixBlendMode: 'darken'
863
+ };
864
+ const theme = createTheme({
865
+ components: {
866
+ [muiName]: {
867
+ variants: [{
868
+ props: testVariantProps,
869
+ style: testStyle
870
+ }]
871
+ }
872
+ }
873
+ });
874
+ const {
875
+ getByTestId
876
+ } = await render(/*#__PURE__*/(0, _jsxRuntime.jsxs)(ThemeProvider, {
877
+ theme: theme,
878
+ children: [/*#__PURE__*/React.cloneElement(element, {
879
+ ...testVariantProps,
880
+ 'data-testid': 'with-props'
881
+ }), /*#__PURE__*/React.cloneElement(element, {
882
+ 'data-testid': 'without-props'
883
+ })]
884
+ }));
885
+ (0, _chai.expect)(getByTestId('with-props')).to.toHaveComputedStyle(testStyle);
886
+ (0, _chai.expect)(getByTestId('without-props')).not.to.toHaveComputedStyle(testStyle);
887
+ });
888
+ _vitest.it.skipIf(window.navigator.userAgent.includes('jsdom'))('supports custom variant', async function test() {
889
+ const {
890
+ muiName,
891
+ testCustomVariant,
892
+ render,
893
+ ThemeProvider,
894
+ createTheme
895
+ } = getOptions();
896
+ if (!ThemeProvider) {
897
+ throwMissingPropError('ThemeProvider');
898
+ }
899
+ if (!createTheme) {
900
+ throwMissingPropError('createTheme');
901
+ }
902
+ if (!testCustomVariant) {
903
+ return;
904
+ }
905
+ const theme = createTheme({
906
+ components: {
907
+ [muiName]: {
908
+ styleOverrides: {
909
+ root: ({
910
+ ownerState
911
+ }) => ({
912
+ ...(ownerState.variant === 'unknown' && {
913
+ mixBlendMode: 'darken'
914
+ })
915
+ })
916
+ }
917
+ }
918
+ }
919
+ });
920
+ const {
921
+ getByTestId
922
+ } = await render(/*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
923
+ theme: theme,
924
+ children: /*#__PURE__*/React.cloneElement(element, {
925
+ variant: 'unknown',
926
+ 'data-testid': 'custom-variant'
927
+ })
928
+ }));
929
+ (0, _chai.expect)(getByTestId('custom-variant')).toHaveComputedStyle({
930
+ mixBlendMode: 'darken'
931
+ });
932
+ });
933
+ });
934
+ }
935
+
936
+ /**
937
+ * MUI theme supports custom palettes.
938
+ * The components that iterate over the palette via `variants` should be able to render with or without applying the custom palette styles.
939
+ */
940
+ function testThemeCustomPalette(element, getOptions) {
941
+ (0, _vitest.describe)('theme extended palette:', () => {
942
+ const {
943
+ render,
944
+ ThemeProvider,
945
+ createTheme
946
+ } = getOptions();
947
+ _vitest.it.skipIf(!window.navigator.userAgent.includes('jsdom') || !render || !ThemeProvider || !createTheme)('should render without errors', function test() {
948
+ var _ThemeProvider;
949
+ // @ts-ignore
950
+ const theme = createTheme({
951
+ palette: {
952
+ custom: {
953
+ main: '#ff5252'
954
+ },
955
+ unknown: null,
956
+ custom2: {
957
+ main: {
958
+ blue: {
959
+ dark: '#FFCC00'
960
+ }
961
+ }
962
+ }
963
+ }
964
+ });
965
+ // @ts-ignore
966
+ (0, _chai.expect)(() => render(_ThemeProvider || (_ThemeProvider = /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeProvider, {
967
+ theme: theme,
968
+ children: element
969
+ })))).not.to.throw();
970
+ });
971
+ });
972
+ }
973
+ const fullSuite = {
974
+ componentProp: testComponentProp,
975
+ componentsProp: testComponentsProp,
976
+ mergeClassName: testClassName,
977
+ propsSpread: testPropsSpread,
978
+ refForwarding: describeRef,
979
+ rootClass: testRootClass,
980
+ slotPropsProp: testSlotPropsProp,
981
+ slotPropsCallback: testSlotPropsCallback,
982
+ slotPropsCallbackWithPropsAsOwnerState: testSlotPropsCallbackWithPropsAsOwnerState,
983
+ slotsProp: testSlotsProp,
984
+ themeDefaultProps: testThemeDefaultProps,
985
+ themeStyleOverrides: testThemeStyleOverrides,
986
+ themeVariants: testThemeVariants,
987
+ themeCustomPalette: testThemeCustomPalette
988
+ };
989
+
990
+ /**
991
+ * Tests various aspects of a component that should be equal across MUI
992
+ * components.
993
+ */
994
+ function describeConformance(minimalElement, getOptions) {
995
+ let originalMatchmedia;
996
+ const storage = {};
997
+ (0, _vitest.beforeEach)(() => {
998
+ originalMatchmedia = window.matchMedia;
999
+ // Create mocks of localStorage getItem and setItem functions
1000
+ Object.defineProperty(globalThis, 'localStorage', {
1001
+ value: {
1002
+ getItem: key => storage[key],
1003
+ setItem: (key, value) => {
1004
+ storage[key] = value;
1005
+ }
1006
+ },
1007
+ configurable: true
1008
+ });
1009
+ window.matchMedia = () => ({
1010
+ // Keep mocking legacy methods because @mui/material v5 still uses them
1011
+ addListener: () => {},
1012
+ addEventListener: () => {},
1013
+ removeListener: () => {},
1014
+ removeEventListener: () => {}
1015
+ });
1016
+ });
1017
+ (0, _vitest.afterEach)(() => {
1018
+ window.matchMedia = originalMatchmedia;
1019
+ });
1020
+ const {
1021
+ after: runAfterHook = () => {},
1022
+ only = Object.keys(fullSuite),
1023
+ slots,
1024
+ skip = []
1025
+ } = getOptions();
1026
+ let filteredTests = Object.keys(fullSuite).filter(testKey => only.includes(testKey) && !skip.includes(testKey));
1027
+ const slotBasedTests = ['slotsProp', 'slotPropsProp', 'slotPropsCallback', 'slotPropsCallbackWithPropsAsOwnerState'];
1028
+ if (!slots) {
1029
+ // if `slots` are not defined, do not run tests that depend on them
1030
+ filteredTests = filteredTests.filter(testKey => !slotBasedTests.includes(testKey));
1031
+ }
1032
+ (0, _vitest.afterAll)(runAfterHook);
1033
+ filteredTests.forEach(testKey => {
1034
+ const test = fullSuite[testKey];
1035
+ test(minimalElement, getOptions);
1036
+ });
1037
+ }
1038
+ var _default = exports.default = (0, _createDescribe.default)('MUI component API', describeConformance);