@mui/internal-test-utils 1.0.0-dev.20240529-082515-213b5e33ab

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 (148) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +9 -0
  4. package/build/.tsbuildinfo +1 -0
  5. package/build/KarmaReporterReactProfiler.d.ts +51 -0
  6. package/build/KarmaReporterReactProfiler.d.ts.map +1 -0
  7. package/build/KarmaReporterReactProfiler.js +68 -0
  8. package/build/KarmaReporterReactProfiler.js.map +1 -0
  9. package/build/components.d.ts +36 -0
  10. package/build/components.d.ts.map +1 -0
  11. package/build/components.js +78 -0
  12. package/build/components.js.map +1 -0
  13. package/build/createDOM.d.ts +3 -0
  14. package/build/createDOM.d.ts.map +1 -0
  15. package/build/createDOM.js +60 -0
  16. package/build/createDOM.js.map +1 -0
  17. package/build/createDescribe.d.ts +8 -0
  18. package/build/createDescribe.d.ts.map +1 -0
  19. package/build/createDescribe.js +22 -0
  20. package/build/createDescribe.js.map +1 -0
  21. package/build/createMount.d.ts +9 -0
  22. package/build/createMount.d.ts.map +1 -0
  23. package/build/createMount.js +120 -0
  24. package/build/createMount.js.map +1 -0
  25. package/build/createRenderer.d.ts +231 -0
  26. package/build/createRenderer.d.ts.map +1 -0
  27. package/build/createRenderer.js +506 -0
  28. package/build/createRenderer.js.map +1 -0
  29. package/build/createRenderer.test.d.ts +2 -0
  30. package/build/createRenderer.test.d.ts.map +1 -0
  31. package/build/createRenderer.test.js +48 -0
  32. package/build/createRenderer.test.js.map +1 -0
  33. package/build/describeConformance.d.ts +152 -0
  34. package/build/describeConformance.d.ts.map +1 -0
  35. package/build/describeConformance.js +815 -0
  36. package/build/describeConformance.js.map +1 -0
  37. package/build/findOutermostIntrinsic.d.ts +14 -0
  38. package/build/findOutermostIntrinsic.d.ts.map +1 -0
  39. package/build/findOutermostIntrinsic.js +22 -0
  40. package/build/findOutermostIntrinsic.js.map +1 -0
  41. package/build/findOutermostIntrinsic.test.d.ts +2 -0
  42. package/build/findOutermostIntrinsic.test.d.ts.map +1 -0
  43. package/build/findOutermostIntrinsic.test.js +70 -0
  44. package/build/findOutermostIntrinsic.test.js.map +1 -0
  45. package/build/fireDiscreteEvent.d.ts +7 -0
  46. package/build/fireDiscreteEvent.d.ts.map +1 -0
  47. package/build/fireDiscreteEvent.js +98 -0
  48. package/build/fireDiscreteEvent.js.map +1 -0
  49. package/build/flushMicrotasks.d.ts +2 -0
  50. package/build/flushMicrotasks.d.ts.map +1 -0
  51. package/build/flushMicrotasks.js +11 -0
  52. package/build/flushMicrotasks.js.map +1 -0
  53. package/build/focusVisible.d.ts +7 -0
  54. package/build/focusVisible.d.ts.map +1 -0
  55. package/build/focusVisible.js +33 -0
  56. package/build/focusVisible.js.map +1 -0
  57. package/build/index.d.ts +18 -0
  58. package/build/index.d.ts.map +1 -0
  59. package/build/index.js +59 -0
  60. package/build/index.js.map +1 -0
  61. package/build/init.d.ts +2 -0
  62. package/build/init.d.ts.map +1 -0
  63. package/build/init.js +42 -0
  64. package/build/init.js.map +1 -0
  65. package/build/initMatchers.d.ts +81 -0
  66. package/build/initMatchers.d.ts.map +1 -0
  67. package/build/initMatchers.js +431 -0
  68. package/build/initMatchers.js.map +1 -0
  69. package/build/initMatchers.test.d.ts +2 -0
  70. package/build/initMatchers.test.d.ts.map +1 -0
  71. package/build/initMatchers.test.js +103 -0
  72. package/build/initMatchers.test.js.map +1 -0
  73. package/build/initPlaywrightMatchers.d.ts +25 -0
  74. package/build/initPlaywrightMatchers.d.ts.map +1 -0
  75. package/build/initPlaywrightMatchers.js +63 -0
  76. package/build/initPlaywrightMatchers.js.map +1 -0
  77. package/build/mochaHooks.d.ts +25 -0
  78. package/build/mochaHooks.d.ts.map +1 -0
  79. package/build/mochaHooks.js +171 -0
  80. package/build/mochaHooks.js.map +1 -0
  81. package/build/mochaHooks.test.d.ts +2 -0
  82. package/build/mochaHooks.test.d.ts.map +1 -0
  83. package/build/mochaHooks.test.js +112 -0
  84. package/build/mochaHooks.test.js.map +1 -0
  85. package/build/setup.d.ts +2 -0
  86. package/build/setup.d.ts.map +1 -0
  87. package/build/setup.js +10 -0
  88. package/build/setup.js.map +1 -0
  89. package/build/setupBabel.d.ts +2 -0
  90. package/build/setupBabel.d.ts.map +1 -0
  91. package/build/setupBabel.js +5 -0
  92. package/build/setupBabel.js.map +1 -0
  93. package/build/setupBabelPlaywright.d.ts +2 -0
  94. package/build/setupBabelPlaywright.d.ts.map +1 -0
  95. package/build/setupBabelPlaywright.js +11 -0
  96. package/build/setupBabelPlaywright.js.map +1 -0
  97. package/build/setupJSDOM.d.ts +7 -0
  98. package/build/setupJSDOM.d.ts.map +1 -0
  99. package/build/setupJSDOM.js +17 -0
  100. package/build/setupJSDOM.js.map +1 -0
  101. package/build/setupKarma.d.ts +2 -0
  102. package/build/setupKarma.d.ts.map +1 -0
  103. package/build/setupKarma.js +56 -0
  104. package/build/setupKarma.js.map +1 -0
  105. package/build/until.d.ts +2 -0
  106. package/build/until.d.ts.map +1 -0
  107. package/build/until.js +26 -0
  108. package/build/until.js.map +1 -0
  109. package/build/until.test.d.ts +2 -0
  110. package/build/until.test.d.ts.map +1 -0
  111. package/build/until.test.js +118 -0
  112. package/build/until.test.js.map +1 -0
  113. package/build/userEvent.d.ts +8 -0
  114. package/build/userEvent.d.ts.map +1 -0
  115. package/build/userEvent.js +61 -0
  116. package/build/userEvent.js.map +1 -0
  117. package/package.json +76 -0
  118. package/src/KarmaReporterReactProfiler.js +81 -0
  119. package/src/components.tsx +61 -0
  120. package/src/createDOM.d.ts +9 -0
  121. package/src/createDOM.js +67 -0
  122. package/src/createDescribe.ts +31 -0
  123. package/src/createMount.tsx +136 -0
  124. package/src/createRenderer.test.js +31 -0
  125. package/src/createRenderer.tsx +737 -0
  126. package/src/describeConformance.tsx +1117 -0
  127. package/src/findOutermostIntrinsic.test.js +68 -0
  128. package/src/findOutermostIntrinsic.ts +19 -0
  129. package/src/fireDiscreteEvent.ts +76 -0
  130. package/src/flushMicrotasks.ts +8 -0
  131. package/src/focusVisible.ts +28 -0
  132. package/src/index.ts +24 -0
  133. package/src/init.js +15 -0
  134. package/src/initMatchers.test.js +126 -0
  135. package/src/initMatchers.ts +658 -0
  136. package/src/initPlaywrightMatchers.ts +96 -0
  137. package/src/mochaHooks.js +209 -0
  138. package/src/mochaHooks.test.js +113 -0
  139. package/src/setup.js +10 -0
  140. package/src/setupBabel.js +3 -0
  141. package/src/setupBabelPlaywright.js +10 -0
  142. package/src/setupJSDOM.js +20 -0
  143. package/src/setupKarma.js +65 -0
  144. package/src/until.js +28 -0
  145. package/src/until.test.js +120 -0
  146. package/src/userEvent.ts +35 -0
  147. package/tsconfig.build.json +17 -0
  148. package/tsconfig.json +12 -0
@@ -0,0 +1,152 @@
1
+ import * as React from 'react';
2
+ import { ReactWrapper } from 'enzyme';
3
+ import { MuiRenderResult } from './createRenderer';
4
+ export interface SlotTestingOptions {
5
+ /**
6
+ * A custom React component to test if the receiving props are correct.
7
+ *
8
+ * It must:
9
+ * - contains at least one DOM which has `data-testid="custom"`
10
+ * - spread `className` to the DOM
11
+ *
12
+ * If not provided, the default custom component tests if the class name is spread.
13
+ */
14
+ testWithComponent?: React.ComponentType;
15
+ /**
16
+ * A custom HTML tag to use for the `slots` prop.
17
+ */
18
+ testWithElement?: keyof React.JSX.IntrinsicElements | null;
19
+ /**
20
+ * To ensure that the slot has this class name when `slotProps` is provided.
21
+ */
22
+ expectedClassName: string;
23
+ isOptional?: boolean;
24
+ }
25
+ interface SlotTestOverride {
26
+ slotName: string;
27
+ slotClassName?: string;
28
+ }
29
+ export interface ConformanceOptions {
30
+ muiName: string;
31
+ classes: {
32
+ root: string;
33
+ };
34
+ refInstanceof: any;
35
+ after?: () => void;
36
+ inheritComponent?: React.ElementType;
37
+ render: (node: React.ReactElement<any>) => MuiRenderResult;
38
+ mount?: (node: React.ReactElement<any>) => ReactWrapper;
39
+ only?: Array<keyof typeof fullSuite>;
40
+ skip?: Array<keyof typeof fullSuite | 'classesRoot'>;
41
+ testComponentsRootPropWith?: string;
42
+ testComponentPropWith?: string | React.ElementType;
43
+ testDeepOverrides?: SlotTestOverride | SlotTestOverride[];
44
+ testRootOverrides?: SlotTestOverride;
45
+ testStateOverrides?: {
46
+ prop?: string;
47
+ value?: any;
48
+ styleKey: string;
49
+ };
50
+ testCustomVariant?: boolean;
51
+ testVariantProps?: object;
52
+ testLegacyComponentsProp?: boolean;
53
+ wrapMount?: (mount: (node: React.ReactElement<any>) => ReactWrapper) => (node: React.ReactElement<any>) => ReactWrapper;
54
+ slots?: Record<string, SlotTestingOptions>;
55
+ ThemeProvider?: React.ElementType;
56
+ createTheme?: (arg: any) => any;
57
+ }
58
+ /**
59
+ * Glossary
60
+ * - root component:
61
+ * - renders the outermost host component
62
+ * - has the `root` class if the component has one
63
+ * - excess props are spread to this component
64
+ * - has the type of `inheritComponent`
65
+ */
66
+ /**
67
+ * Returns the component with the same constructor as `component` that renders
68
+ * the outermost host
69
+ */
70
+ export declare function findRootComponent(wrapper: ReactWrapper, component: string | React.ElementType): ReactWrapper<import("enzyme").HTMLAttributes, any, React.Component<{}, {}, any>>;
71
+ export declare function randomStringValue(): string;
72
+ /**
73
+ * MUI components have a `className` prop. The `className` is applied to
74
+ * the root component.
75
+ */
76
+ export declare function testClassName(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
77
+ /**
78
+ * MUI components have a `component` prop that allows rendering a different
79
+ * Component from @inheritComponent
80
+ */
81
+ export declare function testComponentProp(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
82
+ /**
83
+ * MUI components can spread additional props to a documented component.
84
+ */
85
+ export declare function testPropsSpread(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
86
+ /**
87
+ * Tests that the `ref` of a component will return the correct instance
88
+ *
89
+ * This is determined by a given constructor i.e. a React.Component or HTMLElement for
90
+ * components that forward their ref and attach it to a host component.
91
+ */
92
+ export declare function describeRef(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
93
+ /**
94
+ * Tests that the root component has the root class
95
+ */
96
+ export declare function testRootClass(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
97
+ /**
98
+ * Tests that the component can be rendered with react-test-renderer.
99
+ * This is important for snapshot testing with Jest (even if we don't encourage it).
100
+ */
101
+ export declare function testReactTestRenderer(element: React.ReactElement<any>): void;
102
+ declare function testSlotsProp(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
103
+ declare function testSlotPropsProp(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
104
+ declare function testSlotPropsCallback(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
105
+ /**
106
+ * MUI components have a `components` prop that allows rendering a different
107
+ * Components from @inheritComponent
108
+ */
109
+ declare function testComponentsProp(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
110
+ /**
111
+ * MUI theme has a components section that allows specifying default props.
112
+ * Components from @inheritComponent
113
+ */
114
+ declare function testThemeDefaultProps(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
115
+ /**
116
+ * MUI theme has a components section that allows specifying style overrides.
117
+ * Components from @inheritComponent
118
+ */
119
+ declare function testThemeStyleOverrides(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
120
+ /**
121
+ * MUI theme has a components section that allows specifying custom variants.
122
+ * Components from @inheritComponent
123
+ */
124
+ declare function testThemeVariants(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
125
+ /**
126
+ * MUI theme supports custom palettes.
127
+ * The components that iterate over the palette via `variants` should be able to render with or without applying the custom palette styles.
128
+ */
129
+ declare function testThemeCustomPalette(element: React.ReactElement<any>, getOptions: () => ConformanceOptions): void;
130
+ declare const fullSuite: {
131
+ componentProp: typeof testComponentProp;
132
+ componentsProp: typeof testComponentsProp;
133
+ mergeClassName: typeof testClassName;
134
+ propsSpread: typeof testPropsSpread;
135
+ refForwarding: typeof describeRef;
136
+ rootClass: typeof testRootClass;
137
+ reactTestRenderer: typeof testReactTestRenderer;
138
+ slotPropsProp: typeof testSlotPropsProp;
139
+ slotPropsCallback: typeof testSlotPropsCallback;
140
+ slotsProp: typeof testSlotsProp;
141
+ themeDefaultProps: typeof testThemeDefaultProps;
142
+ themeStyleOverrides: typeof testThemeStyleOverrides;
143
+ themeVariants: typeof testThemeVariants;
144
+ themeCustomPalette: typeof testThemeCustomPalette;
145
+ };
146
+ declare const _default: {
147
+ (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions): void;
148
+ skip: (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions) => void;
149
+ only: (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions) => void;
150
+ };
151
+ export default _default;
152
+ //# sourceMappingURL=describeConformance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeConformance.d.ts","sourceRoot":"","sources":["../src/describeConformance.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAKtC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMnD,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACxC;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,iBAAiB,GAAG,IAAI,CAAC;IAC3D;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,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