@mui/internal-test-utils 2.0.18-canary.2 → 2.0.18-canary.20

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 (41) hide show
  1. package/README.md +23 -12
  2. package/{esm/chaiPlugin.js → chaiPlugin.mjs} +1 -1
  3. package/{esm/createRenderer.d.ts → createRenderer.d.mts} +59 -59
  4. package/createRenderer.d.ts +58 -58
  5. package/{esm/createRenderer.js → createRenderer.mjs} +3 -3
  6. package/{esm/describeConformance.d.ts → describeConformance.d.mts} +2 -20
  7. package/describeConformance.d.ts +0 -18
  8. package/describeConformance.js +2 -173
  9. package/{esm/describeConformance.js → describeConformance.mjs} +4 -175
  10. package/{esm/flushMicrotasks.js → flushMicrotasks.mjs} +1 -1
  11. package/{esm/focusVisible.js → focusVisible.mjs} +1 -1
  12. package/index.d.mts +11 -0
  13. package/index.js +2 -2
  14. package/index.mjs +19 -0
  15. package/initMatchers.d.mts +5 -0
  16. package/{esm/initMatchers.js → initMatchers.mjs} +2 -2
  17. package/package.json +57 -27
  18. package/{esm/setupVitest.d.ts → setupVitest.d.mts} +2 -2
  19. package/setupVitest.js +11 -9
  20. package/{esm/setupVitest.js → setupVitest.mjs} +14 -12
  21. package/esm/index.d.ts +0 -11
  22. package/esm/index.js +0 -19
  23. package/esm/initMatchers.d.ts +0 -5
  24. package/esm/package.json +0 -1
  25. /package/{esm/chaiPlugin.d.ts → chaiPlugin.d.mts} +0 -0
  26. /package/{esm/chaiTypes.d.ts → chaiTypes.d.mts} +0 -0
  27. /package/{esm/chaiTypes.js → chaiTypes.mjs} +0 -0
  28. /package/{esm/components.d.ts → components.d.mts} +0 -0
  29. /package/{esm/components.js → components.mjs} +0 -0
  30. /package/{esm/configure.d.ts → configure.d.mts} +0 -0
  31. /package/{esm/configure.js → configure.mjs} +0 -0
  32. /package/{esm/createDescribe.d.ts → createDescribe.d.mts} +0 -0
  33. /package/{esm/createDescribe.js → createDescribe.mjs} +0 -0
  34. /package/{esm/env.d.ts → env.d.mts} +0 -0
  35. /package/{esm/env.js → env.mjs} +0 -0
  36. /package/{esm/flushMicrotasks.d.ts → flushMicrotasks.d.mts} +0 -0
  37. /package/{esm/focusVisible.d.ts → focusVisible.d.mts} +0 -0
  38. /package/{esm/ignoreActWarnings.d.ts → ignoreActWarnings.d.mts} +0 -0
  39. /package/{esm/ignoreActWarnings.js → ignoreActWarnings.mjs} +0 -0
  40. /package/{esm/initPlaywrightMatchers.d.ts → initPlaywrightMatchers.d.mts} +0 -0
  41. /package/{esm/initPlaywrightMatchers.js → initPlaywrightMatchers.mjs} +0 -0
@@ -18,9 +18,6 @@ var _vitest = require("vitest");
18
18
  var _createDescribe = _interopRequireDefault(require("./createDescribe"));
19
19
  var _env = require("./env");
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
- function capitalize(string) {
22
- return string.charAt(0).toUpperCase() + string.slice(1);
23
- }
24
21
  /**
25
22
  * Glossary
26
23
  * - root component:
@@ -211,8 +208,7 @@ function forEachSlot(slots, callback) {
211
208
  function testSlotsProp(element, getOptions) {
212
209
  const {
213
210
  render,
214
- slots,
215
- testLegacyComponentsProp
211
+ slots
216
212
  } = getOptions();
217
213
  const CustomComponent = /*#__PURE__*/React.forwardRef(({
218
214
  className,
@@ -274,107 +270,12 @@ function testSlotsProp(element, getOptions) {
274
270
  }
275
271
  });
276
272
  }
277
-
278
- // For testing Material UI components v5, and v6. Likely to be removed in a future major release.
279
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
280
- (0, _vitest.it)(`allows overriding the ${slotName} slot with a component using the components.${capitalize(slotName)} prop`, async () => {
281
- if (!render) {
282
- throwMissingPropError('render');
283
- }
284
- const slotComponent = slotOptions.testWithComponent ?? CustomComponent;
285
- const components = {
286
- [capitalize(slotName)]: slotComponent
287
- };
288
- const {
289
- queryByTestId
290
- } = await render(/*#__PURE__*/React.cloneElement(element, {
291
- components
292
- }));
293
- const renderedElement = queryByTestId('custom');
294
- (0, _chai.expect)(renderedElement).not.to.equal(null);
295
- if (slotOptions.expectedClassName) {
296
- (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
297
- }
298
- });
299
- (0, _vitest.it)(`prioritizes the 'slots.${slotName}' over components.${capitalize(slotName)} if both are defined`, async () => {
300
- if (!render) {
301
- throwMissingPropError('render');
302
- }
303
- const ComponentForComponentsProp = /*#__PURE__*/React.forwardRef(({
304
- children
305
- }, ref) => {
306
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
307
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotComponent, {
308
- ref: ref,
309
- "data-testid": "from-components",
310
- children: children
311
- });
312
- });
313
- if (process.env.NODE_ENV !== "production") ComponentForComponentsProp.displayName = "ComponentForComponentsProp";
314
- const ComponentForSlotsProp = /*#__PURE__*/React.forwardRef(({
315
- children
316
- }, ref) => {
317
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
318
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(SlotComponent, {
319
- ref: ref,
320
- "data-testid": "from-slots",
321
- children: children
322
- });
323
- });
324
- if (process.env.NODE_ENV !== "production") ComponentForSlotsProp.displayName = "ComponentForSlotsProp";
325
- const components = {
326
- [capitalize(slotName)]: ComponentForComponentsProp
327
- };
328
- const slotOverrides = {
329
- [slotName]: ComponentForSlotsProp
330
- };
331
- const {
332
- queryByTestId
333
- } = await render(/*#__PURE__*/React.cloneElement(element, {
334
- components,
335
- slots: slotOverrides
336
- }));
337
- (0, _chai.expect)(queryByTestId('from-slots')).not.to.equal(null);
338
- (0, _chai.expect)(queryByTestId('from-components')).to.equal(null);
339
- });
340
- if (slotOptions.testWithElement !== null) {
341
- (0, _vitest.it)(`allows overriding the ${slotName} slot with an element using the components.${capitalize(slotName)} prop`, async () => {
342
- if (!render) {
343
- throwMissingPropError('render');
344
- }
345
- const slotElement = slotOptions.testWithElement ?? 'i';
346
- const components = {
347
- [capitalize(slotName)]: slotElement
348
- };
349
- const componentsProps = {
350
- [slotName]: {
351
- 'data-testid': 'customized'
352
- }
353
- };
354
- const {
355
- queryByTestId
356
- } = await render(/*#__PURE__*/React.cloneElement(element, {
357
- components,
358
- componentsProps
359
- }));
360
- const renderedElement = queryByTestId('customized');
361
- (0, _chai.expect)(renderedElement).not.to.equal(null);
362
- if (typeof slotElement === 'string') {
363
- (0, _chai.expect)(renderedElement.nodeName.toLowerCase()).to.equal(slotElement);
364
- }
365
- if (slotOptions.expectedClassName) {
366
- (0, _chai.expect)(renderedElement).to.have.class(slotOptions.expectedClassName);
367
- }
368
- });
369
- }
370
- }
371
273
  });
372
274
  }
373
275
  function testSlotPropsProp(element, getOptions) {
374
276
  const {
375
277
  render,
376
- slots,
377
- testLegacyComponentsProp
278
+ slots
378
279
  } = getOptions();
379
280
  if (!render) {
380
281
  throwMissingPropError('render');
@@ -414,48 +315,6 @@ function testSlotPropsProp(element, getOptions) {
414
315
  (0, _chai.expect)(getByTestId('custom')).to.have.class(slotProps[slotName].className);
415
316
  });
416
317
  }
417
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
418
- (0, _vitest.it)(`sets custom properties on the ${slotName} slot's element with the componentsProps.${slotName} prop`, async () => {
419
- const componentsProps = {
420
- [slotName]: {
421
- 'data-testid': 'custom'
422
- }
423
- };
424
- const {
425
- queryByTestId
426
- } = await render(/*#__PURE__*/React.cloneElement(element, {
427
- componentsProps
428
- }));
429
- const slotComponent = queryByTestId('custom');
430
- (0, _chai.expect)(slotComponent).not.to.equal(null);
431
- if (slotOptions.expectedClassName) {
432
- (0, _chai.expect)(slotComponent).to.have.class(slotOptions.expectedClassName);
433
- }
434
- });
435
- (0, _vitest.it)(`prioritizes the 'slotProps.${slotName}' over componentsProps.${slotName} if both are defined`, async () => {
436
- const componentsProps = {
437
- [slotName]: {
438
- 'data-testid': 'custom',
439
- 'data-from-components-props': 'true'
440
- }
441
- };
442
- const slotProps = {
443
- [slotName]: {
444
- 'data-testid': 'custom',
445
- 'data-from-slot-props': 'true'
446
- }
447
- };
448
- const {
449
- queryByTestId
450
- } = await render(/*#__PURE__*/React.cloneElement(element, {
451
- componentsProps,
452
- slotProps
453
- }));
454
- const slotComponent = queryByTestId('custom');
455
- (0, _chai.expect)(slotComponent).to.have.attribute('data-from-slot-props', 'true');
456
- (0, _chai.expect)(slotComponent).not.to.have.attribute('data-from-components-props');
457
- });
458
- }
459
318
  });
460
319
  }
461
320
  function testSlotPropsCallback(element, getOptions) {
@@ -513,35 +372,6 @@ function testSlotPropsCallbackWithPropsAsOwnerState(element, getOptions) {
513
372
  });
514
373
  }
515
374
 
516
- /**
517
- * MUI components have a `components` prop that allows rendering a different
518
- * Components from @inheritComponent
519
- */
520
- function testComponentsProp(element, getOptions) {
521
- (0, _vitest.describe)('prop components:', () => {
522
- (0, _vitest.it)('can render another root component with the `components` prop', async () => {
523
- const {
524
- render,
525
- testComponentsRootPropWith: component = 'em'
526
- } = getOptions();
527
- if (!render) {
528
- throwMissingPropError('render');
529
- }
530
- const testId = randomStringValue();
531
- const {
532
- getByTestId
533
- } = await render(/*#__PURE__*/React.cloneElement(element, {
534
- components: {
535
- Root: component
536
- },
537
- 'data-testid': testId
538
- }));
539
- (0, _chai.expect)(getByTestId(testId)).not.to.equal(null);
540
- (0, _chai.expect)(getByTestId(testId).nodeName.toLowerCase()).to.eq(component);
541
- });
542
- });
543
- }
544
-
545
375
  /**
546
376
  * MUI theme has a components section that allows specifying default props.
547
377
  * Components from @inheritComponent
@@ -977,7 +807,6 @@ function testThemeCustomPalette(element, getOptions) {
977
807
  }
978
808
  const fullSuite = {
979
809
  componentProp: testComponentProp,
980
- componentsProp: testComponentsProp,
981
810
  mergeClassName: testClassName,
982
811
  propsSpread: testPropsSpread,
983
812
  refForwarding: describeRef,
@@ -1,12 +1,9 @@
1
1
  import { expect } from 'chai';
2
2
  import * as React from 'react';
3
3
  import { describe, it, afterAll, afterEach, beforeEach } from 'vitest';
4
- import createDescribe from "./createDescribe.js";
5
- import { isJsdom } from "./env.js";
4
+ import createDescribe from "./createDescribe.mjs";
5
+ import { isJsdom } from "./env.mjs";
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
- function capitalize(string) {
8
- return string.charAt(0).toUpperCase() + string.slice(1);
9
- }
10
7
  /**
11
8
  * Glossary
12
9
  * - root component:
@@ -197,8 +194,7 @@ function forEachSlot(slots, callback) {
197
194
  function testSlotsProp(element, getOptions) {
198
195
  const {
199
196
  render,
200
- slots,
201
- testLegacyComponentsProp
197
+ slots
202
198
  } = getOptions();
203
199
  const CustomComponent = /*#__PURE__*/React.forwardRef(({
204
200
  className,
@@ -260,107 +256,12 @@ function testSlotsProp(element, getOptions) {
260
256
  }
261
257
  });
262
258
  }
263
-
264
- // For testing Material UI components v5, and v6. Likely to be removed in a future major release.
265
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
266
- it(`allows overriding the ${slotName} slot with a component using the components.${capitalize(slotName)} prop`, async () => {
267
- if (!render) {
268
- throwMissingPropError('render');
269
- }
270
- const slotComponent = slotOptions.testWithComponent ?? CustomComponent;
271
- const components = {
272
- [capitalize(slotName)]: slotComponent
273
- };
274
- const {
275
- queryByTestId
276
- } = await render(/*#__PURE__*/React.cloneElement(element, {
277
- components
278
- }));
279
- const renderedElement = queryByTestId('custom');
280
- expect(renderedElement).not.to.equal(null);
281
- if (slotOptions.expectedClassName) {
282
- expect(renderedElement).to.have.class(slotOptions.expectedClassName);
283
- }
284
- });
285
- it(`prioritizes the 'slots.${slotName}' over components.${capitalize(slotName)} if both are defined`, async () => {
286
- if (!render) {
287
- throwMissingPropError('render');
288
- }
289
- const ComponentForComponentsProp = /*#__PURE__*/React.forwardRef(({
290
- children
291
- }, ref) => {
292
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
293
- return /*#__PURE__*/_jsx(SlotComponent, {
294
- ref: ref,
295
- "data-testid": "from-components",
296
- children: children
297
- });
298
- });
299
- if (process.env.NODE_ENV !== "production") ComponentForComponentsProp.displayName = "ComponentForComponentsProp";
300
- const ComponentForSlotsProp = /*#__PURE__*/React.forwardRef(({
301
- children
302
- }, ref) => {
303
- const SlotComponent = slotOptions.testWithComponent ?? 'div';
304
- return /*#__PURE__*/_jsx(SlotComponent, {
305
- ref: ref,
306
- "data-testid": "from-slots",
307
- children: children
308
- });
309
- });
310
- if (process.env.NODE_ENV !== "production") ComponentForSlotsProp.displayName = "ComponentForSlotsProp";
311
- const components = {
312
- [capitalize(slotName)]: ComponentForComponentsProp
313
- };
314
- const slotOverrides = {
315
- [slotName]: ComponentForSlotsProp
316
- };
317
- const {
318
- queryByTestId
319
- } = await render(/*#__PURE__*/React.cloneElement(element, {
320
- components,
321
- slots: slotOverrides
322
- }));
323
- expect(queryByTestId('from-slots')).not.to.equal(null);
324
- expect(queryByTestId('from-components')).to.equal(null);
325
- });
326
- if (slotOptions.testWithElement !== null) {
327
- it(`allows overriding the ${slotName} slot with an element using the components.${capitalize(slotName)} prop`, async () => {
328
- if (!render) {
329
- throwMissingPropError('render');
330
- }
331
- const slotElement = slotOptions.testWithElement ?? 'i';
332
- const components = {
333
- [capitalize(slotName)]: slotElement
334
- };
335
- const componentsProps = {
336
- [slotName]: {
337
- 'data-testid': 'customized'
338
- }
339
- };
340
- const {
341
- queryByTestId
342
- } = await render(/*#__PURE__*/React.cloneElement(element, {
343
- components,
344
- componentsProps
345
- }));
346
- const renderedElement = queryByTestId('customized');
347
- expect(renderedElement).not.to.equal(null);
348
- if (typeof slotElement === 'string') {
349
- expect(renderedElement.nodeName.toLowerCase()).to.equal(slotElement);
350
- }
351
- if (slotOptions.expectedClassName) {
352
- expect(renderedElement).to.have.class(slotOptions.expectedClassName);
353
- }
354
- });
355
- }
356
- }
357
259
  });
358
260
  }
359
261
  function testSlotPropsProp(element, getOptions) {
360
262
  const {
361
263
  render,
362
- slots,
363
- testLegacyComponentsProp
264
+ slots
364
265
  } = getOptions();
365
266
  if (!render) {
366
267
  throwMissingPropError('render');
@@ -400,48 +301,6 @@ function testSlotPropsProp(element, getOptions) {
400
301
  expect(getByTestId('custom')).to.have.class(slotProps[slotName].className);
401
302
  });
402
303
  }
403
- if (testLegacyComponentsProp === true || Array.isArray(testLegacyComponentsProp) && testLegacyComponentsProp.includes(slotName)) {
404
- it(`sets custom properties on the ${slotName} slot's element with the componentsProps.${slotName} prop`, async () => {
405
- const componentsProps = {
406
- [slotName]: {
407
- 'data-testid': 'custom'
408
- }
409
- };
410
- const {
411
- queryByTestId
412
- } = await render(/*#__PURE__*/React.cloneElement(element, {
413
- componentsProps
414
- }));
415
- const slotComponent = queryByTestId('custom');
416
- expect(slotComponent).not.to.equal(null);
417
- if (slotOptions.expectedClassName) {
418
- expect(slotComponent).to.have.class(slotOptions.expectedClassName);
419
- }
420
- });
421
- it(`prioritizes the 'slotProps.${slotName}' over componentsProps.${slotName} if both are defined`, async () => {
422
- const componentsProps = {
423
- [slotName]: {
424
- 'data-testid': 'custom',
425
- 'data-from-components-props': 'true'
426
- }
427
- };
428
- const slotProps = {
429
- [slotName]: {
430
- 'data-testid': 'custom',
431
- 'data-from-slot-props': 'true'
432
- }
433
- };
434
- const {
435
- queryByTestId
436
- } = await render(/*#__PURE__*/React.cloneElement(element, {
437
- componentsProps,
438
- slotProps
439
- }));
440
- const slotComponent = queryByTestId('custom');
441
- expect(slotComponent).to.have.attribute('data-from-slot-props', 'true');
442
- expect(slotComponent).not.to.have.attribute('data-from-components-props');
443
- });
444
- }
445
304
  });
446
305
  }
447
306
  function testSlotPropsCallback(element, getOptions) {
@@ -499,35 +358,6 @@ function testSlotPropsCallbackWithPropsAsOwnerState(element, getOptions) {
499
358
  });
500
359
  }
501
360
 
502
- /**
503
- * MUI components have a `components` prop that allows rendering a different
504
- * Components from @inheritComponent
505
- */
506
- function testComponentsProp(element, getOptions) {
507
- describe('prop components:', () => {
508
- it('can render another root component with the `components` prop', async () => {
509
- const {
510
- render,
511
- testComponentsRootPropWith: component = 'em'
512
- } = getOptions();
513
- if (!render) {
514
- throwMissingPropError('render');
515
- }
516
- const testId = randomStringValue();
517
- const {
518
- getByTestId
519
- } = await render(/*#__PURE__*/React.cloneElement(element, {
520
- components: {
521
- Root: component
522
- },
523
- 'data-testid': testId
524
- }));
525
- expect(getByTestId(testId)).not.to.equal(null);
526
- expect(getByTestId(testId).nodeName.toLowerCase()).to.eq(component);
527
- });
528
- });
529
- }
530
-
531
361
  /**
532
362
  * MUI theme has a components section that allows specifying default props.
533
363
  * Components from @inheritComponent
@@ -963,7 +793,6 @@ function testThemeCustomPalette(element, getOptions) {
963
793
  }
964
794
  const fullSuite = {
965
795
  componentProp: testComponentProp,
966
- componentsProp: testComponentsProp,
967
796
  mergeClassName: testClassName,
968
797
  propsSpread: testPropsSpread,
969
798
  refForwarding: describeRef,
@@ -1,4 +1,4 @@
1
- import { act } from "./createRenderer.js";
1
+ import { act } from "./createRenderer.mjs";
2
2
  export async function flushMicrotasks() {
3
3
  await act(async () => {});
4
4
  }
@@ -1,4 +1,4 @@
1
- import { act, fireEvent } from "./createRenderer.js";
1
+ import { act, fireEvent } from "./createRenderer.mjs";
2
2
  export default function focusVisible(element) {
3
3
  act(() => {
4
4
  element.blur();
package/index.d.mts ADDED
@@ -0,0 +1,11 @@
1
+ import "./initMatchers.mjs";
2
+ export * from "./components.mjs";
3
+ export { default as describeConformance } from "./describeConformance.mjs";
4
+ export * from "./describeConformance.mjs";
5
+ export { default as createDescribe } from "./createDescribe.mjs";
6
+ export * from "./createRenderer.mjs";
7
+ export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.mjs";
8
+ export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
9
+ export { flushMicrotasks } from "./flushMicrotasks.mjs";
10
+ export * from "./env.mjs";
11
+ export { ignoreActWarnings } from "./ignoreActWarnings.mjs";
package/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @mui/internal-test-utils v2.0.17
3
3
  *
4
- * @license undefined
5
- * This source code is licensed under the undefined license found in the
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  "use strict";
package/index.mjs ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @mui/internal-test-utils v2.0.17
3
+ *
4
+ * @license MIT
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ import "./initMatchers.mjs";
9
+ export * from "./components.mjs";
10
+ export { default as describeConformance } from "./describeConformance.mjs";
11
+ export * from "./describeConformance.mjs";
12
+ export { default as createDescribe } from "./createDescribe.mjs";
13
+ export * from "./createRenderer.mjs";
14
+ export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.mjs";
15
+ // eslint-disable-next-line import/extensions
16
+ export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
17
+ export { flushMicrotasks } from "./flushMicrotasks.mjs";
18
+ export * from "./env.mjs";
19
+ export { ignoreActWarnings } from "./ignoreActWarnings.mjs";
@@ -0,0 +1,5 @@
1
+ import * as chai from 'chai';
2
+ import chaiDom from 'chai-dom';
3
+ import "./chaiTypes.mjs";
4
+ import chaiPlugin from "./chaiPlugin.mjs";
5
+ export { chai, chaiDom, chaiPlugin };
@@ -1,7 +1,7 @@
1
1
  import * as chai from 'chai';
2
2
  import chaiDom from 'chai-dom';
3
- import "./chaiTypes.js";
4
- import chaiPlugin from "./chaiPlugin.js";
3
+ import "./chaiTypes.mjs";
4
+ import chaiPlugin from "./chaiPlugin.mjs";
5
5
  chai.use(chaiDom);
6
6
  chai.use(chaiPlugin);
7
7