@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,200 @@
1
+ import * as React from 'react';
2
+ import { MuiRenderResult } from "./createRenderer.js";
3
+ interface DataProps {
4
+ [key: `data-${string}`]: string;
5
+ }
6
+ export interface SlotTestingOptions {
7
+ /**
8
+ * A custom React component to test if the receiving props are correct.
9
+ *
10
+ * It must:
11
+ * - contains at least one DOM which has `data-testid="custom"`
12
+ * - spread `className` to the DOM
13
+ *
14
+ * If not provided, the default custom component tests if the class name is spread.
15
+ */
16
+ testWithComponent?: React.ComponentType;
17
+ /**
18
+ * A custom HTML tag to use for the `slots` prop.
19
+ */
20
+ testWithElement?: keyof React.JSX.IntrinsicElements | null;
21
+ /**
22
+ * To ensure that the slot has this class name when `slotProps` is provided.
23
+ */
24
+ expectedClassName: string;
25
+ isOptional?: boolean;
26
+ }
27
+ interface SlotTestOverride {
28
+ slotName: string;
29
+ slotClassName?: string;
30
+ }
31
+ export interface ConformanceOptions {
32
+ muiName: string;
33
+ classes: {
34
+ root: string;
35
+ };
36
+ refInstanceof: any;
37
+ after?: () => void;
38
+ inheritComponent?: React.ElementType;
39
+ render: (node: React.ReactElement<DataProps>) => MuiRenderResult | Promise<MuiRenderResult>;
40
+ only?: Array<keyof typeof fullSuite>;
41
+ skip?: Array<keyof typeof fullSuite | 'classesRoot'>;
42
+ testComponentsRootPropWith?: string;
43
+ /**
44
+ * A custom React component to test if the component prop is implemented correctly.
45
+ *
46
+ * It must either:
47
+ * - Be a string that is a valid HTML tag, or
48
+ * - A component that spread props to the underlying rendered element.
49
+ *
50
+ * If not provided, the default 'em' element is used.
51
+ */
52
+ testComponentPropWith?: string | React.ElementType;
53
+ testDeepOverrides?: SlotTestOverride | SlotTestOverride[];
54
+ testRootOverrides?: SlotTestOverride;
55
+ testStateOverrides?: {
56
+ prop?: string;
57
+ value?: any;
58
+ styleKey: string;
59
+ };
60
+ testCustomVariant?: boolean;
61
+ testVariantProps?: object;
62
+ testLegacyComponentsProp?: boolean | string[];
63
+ slots?: Record<string, SlotTestingOptions>;
64
+ ThemeProvider?: React.ElementType;
65
+ /**
66
+ * If provided, the component will be tested by the `DefaultPropsProvider` (in addition to the ThemeProvider).
67
+ */
68
+ DefaultPropsProvider?: React.ElementType;
69
+ createTheme?: (arg: any) => any;
70
+ }
71
+ /**
72
+ * Glossary
73
+ * - root component:
74
+ * - renders the outermost host component
75
+ * - has the `root` class if the component has one
76
+ * - excess props are spread to this component
77
+ * - has the type of `inheritComponent`
78
+ */
79
+ export declare function randomStringValue(): string;
80
+ /**
81
+ * MUI components have a `className` prop. The `className` is applied to
82
+ * the root component.
83
+ */
84
+ export declare function testClassName(element: React.ReactElement<DataProps & {
85
+ className: string;
86
+ }>, getOptions: () => ConformanceOptions): void;
87
+ /**
88
+ * MUI components have a `component` prop that allows rendering a different
89
+ * Component from @inheritComponent
90
+ */
91
+ export declare function testComponentProp(element: React.ReactElement<DataProps & {
92
+ className: string;
93
+ component?: string | React.ElementType;
94
+ }>, getOptions: () => ConformanceOptions): void;
95
+ /**
96
+ * MUI components spread additional props to its root.
97
+ */
98
+ export declare function testPropsSpread(element: React.ReactElement<DataProps & {
99
+ className: string;
100
+ component: string | React.ElementType;
101
+ }>, getOptions: () => ConformanceOptions): void;
102
+ /**
103
+ * Tests that the `ref` of a component will return the correct instance
104
+ *
105
+ * This is determined by a given constructor i.e. a React.Component or HTMLElement for
106
+ * components that forward their ref and attach it to a host component.
107
+ */
108
+ export declare function describeRef(element: React.ReactElement<{
109
+ ref: React.RefObject<any>;
110
+ }>, getOptions: () => ConformanceOptions): void;
111
+ /**
112
+ * Tests that the root component has the root class
113
+ */
114
+ export declare function testRootClass(element: React.ReactElement<{
115
+ className: string;
116
+ classes: Record<string, string>;
117
+ }>, getOptions: () => ConformanceOptions): void;
118
+ declare function testSlotsProp(element: React.ReactElement<{
119
+ className: string;
120
+ classes: Record<string, string>;
121
+ slots: {
122
+ [x: string]: SlotTestingOptions['testWithComponent'] | keyof React.JSX.IntrinsicElements | React.ForwardRefExoticComponent<{
123
+ children: React.ReactNode;
124
+ } & React.RefAttributes<HTMLDivElement>>;
125
+ };
126
+ components?: {
127
+ [x: string]: SlotTestingOptions['testWithComponent'] | keyof React.JSX.IntrinsicElements | React.ForwardRefExoticComponent<{
128
+ children: React.ReactNode;
129
+ } & React.RefAttributes<HTMLDivElement>>;
130
+ };
131
+ slotProps: {
132
+ [x: string]: DataProps;
133
+ };
134
+ componentsProps?: {
135
+ [x: string]: DataProps;
136
+ };
137
+ }>, getOptions: () => ConformanceOptions): void;
138
+ declare function testSlotPropsProp(element: React.ReactElement<{
139
+ componentsProps?: Record<string, DataProps>;
140
+ slotProps: Record<string, DataProps>;
141
+ }>, getOptions: () => ConformanceOptions): void;
142
+ declare function testSlotPropsCallback(element: React.ReactElement<{
143
+ slotProps: Record<string, () => DataProps>;
144
+ className: string;
145
+ }>, getOptions: () => ConformanceOptions): void;
146
+ declare function testSlotPropsCallbackWithPropsAsOwnerState(element: React.ReactElement<{
147
+ slotProps: Record<string, (ownerState: Record<string, any>) => DataProps>;
148
+ className: string;
149
+ }>, getOptions: () => ConformanceOptions): void;
150
+ /**
151
+ * MUI components have a `components` prop that allows rendering a different
152
+ * Components from @inheritComponent
153
+ */
154
+ declare function testComponentsProp(element: React.ReactElement<{
155
+ components?: Record<string, string>;
156
+ } & DataProps>, getOptions: () => ConformanceOptions): void;
157
+ /**
158
+ * MUI theme has a components section that allows specifying default props.
159
+ * Components from @inheritComponent
160
+ */
161
+ declare function testThemeDefaultProps(element: React.ReactElement<unknown>, getOptions: () => ConformanceOptions): void;
162
+ /**
163
+ * MUI theme has a components section that allows specifying style overrides.
164
+ * Components from @inheritComponent
165
+ */
166
+ declare function testThemeStyleOverrides(element: React.ReactElement<unknown>, getOptions: () => ConformanceOptions): void;
167
+ /**
168
+ * MUI theme has a components section that allows specifying custom variants.
169
+ * Components from @inheritComponent
170
+ */
171
+ declare function testThemeVariants(element: React.ReactElement<DataProps & {
172
+ variant: string;
173
+ }>, getOptions: () => ConformanceOptions): void;
174
+ /**
175
+ * MUI theme supports custom palettes.
176
+ * The components that iterate over the palette via `variants` should be able to render with or without applying the custom palette styles.
177
+ */
178
+ declare function testThemeCustomPalette(element: React.ReactElement<unknown>, getOptions: () => ConformanceOptions): void;
179
+ declare const fullSuite: {
180
+ componentProp: typeof testComponentProp;
181
+ componentsProp: typeof testComponentsProp;
182
+ mergeClassName: typeof testClassName;
183
+ propsSpread: typeof testPropsSpread;
184
+ refForwarding: typeof describeRef;
185
+ rootClass: typeof testRootClass;
186
+ slotPropsProp: typeof testSlotPropsProp;
187
+ slotPropsCallback: typeof testSlotPropsCallback;
188
+ slotPropsCallbackWithPropsAsOwnerState: typeof testSlotPropsCallbackWithPropsAsOwnerState;
189
+ slotsProp: typeof testSlotsProp;
190
+ themeDefaultProps: typeof testThemeDefaultProps;
191
+ themeStyleOverrides: typeof testThemeStyleOverrides;
192
+ themeVariants: typeof testThemeVariants;
193
+ themeCustomPalette: typeof testThemeCustomPalette;
194
+ };
195
+ declare const _default: {
196
+ (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions): void;
197
+ skip: (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions) => void;
198
+ only: (minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions) => void;
199
+ };
200
+ export default _default;