@mui/internal-test-utils 2.0.14 → 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.
- package/{src/chai.types.ts → chai.types.d.ts} +7 -40
- package/chai.types.js +5 -0
- package/chaiPlugin.d.ts +4 -0
- package/chaiPlugin.js +287 -0
- package/{build/components.d.ts → components.d.ts} +18 -19
- package/components.js +64 -0
- package/createDOM.d.ts +2 -0
- package/{src/createDOM.js → createDOM.js} +17 -35
- package/createDescribe.d.ts +7 -0
- package/createDescribe.js +26 -0
- package/createRenderer.d.ts +214 -0
- package/createRenderer.js +428 -0
- package/createRenderer.test.d.ts +1 -0
- package/describeConformance.d.ts +200 -0
- package/describeConformance.js +1038 -0
- package/env.d.ts +1 -0
- package/env.js +11 -0
- package/esm/chai.types.d.ts +74 -0
- package/esm/chai.types.js +3 -0
- package/esm/chaiPlugin.d.ts +4 -0
- package/esm/chaiPlugin.js +281 -0
- package/esm/components.d.ts +35 -0
- package/esm/components.js +56 -0
- package/esm/createDOM.d.ts +2 -0
- package/esm/createDOM.js +47 -0
- package/esm/createDescribe.d.ts +7 -0
- package/esm/createDescribe.js +19 -0
- package/esm/createRenderer.d.ts +214 -0
- package/esm/createRenderer.js +390 -0
- package/esm/createRenderer.test.d.ts +1 -0
- package/esm/describeConformance.d.ts +200 -0
- package/esm/describeConformance.js +1024 -0
- package/esm/env.d.ts +1 -0
- package/esm/env.js +5 -0
- package/{build → esm}/fireDiscreteEvent.d.ts +1 -2
- package/{src/fireDiscreteEvent.ts → esm/fireDiscreteEvent.js} +10 -18
- package/esm/flushMicrotasks.d.ts +1 -0
- package/{src/flushMicrotasks.ts → esm/flushMicrotasks.js} +2 -3
- package/{build → esm}/focusVisible.d.ts +1 -2
- package/{src/focusVisible.ts → esm/focusVisible.js} +10 -9
- package/esm/index.d.ts +18 -0
- package/esm/index.js +27 -0
- package/esm/init.d.ts +1 -0
- package/{src → esm}/init.js +4 -2
- package/esm/initMatchers.d.ts +1 -0
- package/esm/initMatchers.js +6 -0
- package/esm/initMatchers.test.d.ts +1 -0
- package/esm/initPlaywrightMatchers.d.ts +24 -0
- package/esm/initPlaywrightMatchers.js +40 -0
- package/esm/package.json +1 -0
- package/esm/reactMajor.d.ts +2 -0
- package/esm/reactMajor.js +2 -0
- package/esm/setup.d.ts +1 -0
- package/{src → esm}/setup.js +2 -4
- package/esm/setupVitest.d.ts +1 -0
- package/esm/setupVitest.js +28 -0
- package/esm/setupVitestBrowser.d.ts +1 -0
- package/esm/setupVitestBrowser.js +30 -0
- package/fireDiscreteEvent.d.ts +6 -0
- package/fireDiscreteEvent.js +79 -0
- package/flushMicrotasks.d.ts +1 -0
- package/flushMicrotasks.js +10 -0
- package/focusVisible.d.ts +7 -0
- package/focusVisible.js +44 -0
- package/index.d.ts +18 -0
- package/index.js +139 -0
- package/init.d.ts +1 -0
- package/init.js +15 -0
- package/initMatchers.d.ts +1 -0
- package/initMatchers.js +10 -0
- package/initMatchers.test.d.ts +1 -0
- package/initPlaywrightMatchers.d.ts +24 -0
- package/initPlaywrightMatchers.js +42 -0
- package/package.json +89 -46
- package/reactMajor.d.ts +2 -0
- package/reactMajor.js +9 -0
- package/setup.d.ts +1 -0
- package/setup.js +10 -0
- package/setupVitest.d.ts +1 -0
- package/setupVitest.js +32 -0
- package/setupVitestBrowser.d.ts +1 -0
- package/setupVitestBrowser.js +34 -0
- package/build/.tsbuildinfo +0 -1
- package/build/KarmaReporterReactProfiler.d.ts +0 -51
- package/build/KarmaReporterReactProfiler.d.ts.map +0 -1
- package/build/KarmaReporterReactProfiler.js +0 -66
- package/build/KarmaReporterReactProfiler.js.map +0 -1
- package/build/chai.types.d.ts +0 -75
- package/build/chai.types.d.ts.map +0 -1
- package/build/chai.types.js +0 -3
- package/build/chai.types.js.map +0 -1
- package/build/chaiPlugin.d.ts +0 -5
- package/build/chaiPlugin.d.ts.map +0 -1
- package/build/chaiPlugin.js +0 -417
- package/build/chaiPlugin.js.map +0 -1
- package/build/components.d.ts.map +0 -1
- package/build/components.js +0 -88
- package/build/components.js.map +0 -1
- package/build/createDOM.d.ts +0 -3
- package/build/createDOM.d.ts.map +0 -1
- package/build/createDOM.js +0 -60
- package/build/createDOM.js.map +0 -1
- package/build/createDescribe.d.ts +0 -8
- package/build/createDescribe.d.ts.map +0 -1
- package/build/createDescribe.js +0 -22
- package/build/createDescribe.js.map +0 -1
- package/build/createRenderer.d.ts +0 -215
- package/build/createRenderer.d.ts.map +0 -1
- package/build/createRenderer.js +0 -565
- package/build/createRenderer.js.map +0 -1
- package/build/createRenderer.test.d.ts +0 -2
- package/build/createRenderer.test.d.ts.map +0 -1
- package/build/createRenderer.test.js +0 -58
- package/build/createRenderer.test.js.map +0 -1
- package/build/describeConformance.d.ts +0 -201
- package/build/describeConformance.d.ts.map +0 -1
- package/build/describeConformance.js +0 -859
- package/build/describeConformance.js.map +0 -1
- package/build/describeSkipIf.d.ts +0 -4
- package/build/describeSkipIf.d.ts.map +0 -1
- package/build/describeSkipIf.js +0 -10
- package/build/describeSkipIf.js.map +0 -1
- package/build/fireDiscreteEvent.d.ts.map +0 -1
- package/build/fireDiscreteEvent.js +0 -77
- package/build/fireDiscreteEvent.js.map +0 -1
- package/build/flushMicrotasks.d.ts +0 -2
- package/build/flushMicrotasks.d.ts.map +0 -1
- package/build/flushMicrotasks.js +0 -8
- package/build/flushMicrotasks.js.map +0 -1
- package/build/focusVisible.d.ts.map +0 -1
- package/build/focusVisible.js +0 -38
- package/build/focusVisible.js.map +0 -1
- package/build/index.d.ts +0 -18
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -68
- package/build/index.js.map +0 -1
- package/build/init.d.ts +0 -2
- package/build/init.d.ts.map +0 -1
- package/build/init.js +0 -46
- package/build/init.js.map +0 -1
- package/build/initMatchers.d.ts +0 -2
- package/build/initMatchers.d.ts.map +0 -1
- package/build/initMatchers.js +0 -45
- package/build/initMatchers.js.map +0 -1
- package/build/initMatchers.test.d.ts +0 -2
- package/build/initMatchers.test.d.ts.map +0 -1
- package/build/initMatchers.test.js +0 -101
- package/build/initMatchers.test.js.map +0 -1
- package/build/initPlaywrightMatchers.d.ts +0 -25
- package/build/initPlaywrightMatchers.d.ts.map +0 -1
- package/build/initPlaywrightMatchers.js +0 -73
- package/build/initPlaywrightMatchers.js.map +0 -1
- package/build/mochaHooks.d.ts +0 -24
- package/build/mochaHooks.d.ts.map +0 -1
- package/build/mochaHooks.js +0 -165
- package/build/mochaHooks.js.map +0 -1
- package/build/mochaHooks.test.d.ts +0 -2
- package/build/mochaHooks.test.d.ts.map +0 -1
- package/build/mochaHooks.test.js +0 -127
- package/build/mochaHooks.test.js.map +0 -1
- package/build/reactMajor.d.ts +0 -3
- package/build/reactMajor.d.ts.map +0 -1
- package/build/reactMajor.js +0 -38
- package/build/reactMajor.js.map +0 -1
- package/build/setup.d.ts +0 -2
- package/build/setup.d.ts.map +0 -1
- package/build/setup.js +0 -10
- package/build/setup.js.map +0 -1
- package/build/setupBabel.d.ts +0 -2
- package/build/setupBabel.d.ts.map +0 -1
- package/build/setupBabel.js +0 -5
- package/build/setupBabel.js.map +0 -1
- package/build/setupBabelPlaywright.d.ts +0 -2
- package/build/setupBabelPlaywright.d.ts.map +0 -1
- package/build/setupBabelPlaywright.js +0 -14
- package/build/setupBabelPlaywright.js.map +0 -1
- package/build/setupJSDOM.d.ts +0 -7
- package/build/setupJSDOM.d.ts.map +0 -1
- package/build/setupJSDOM.js +0 -17
- package/build/setupJSDOM.js.map +0 -1
- package/build/setupKarma.d.ts +0 -2
- package/build/setupKarma.d.ts.map +0 -1
- package/build/setupKarma.js +0 -56
- package/build/setupKarma.js.map +0 -1
- package/build/setupVitest.d.ts +0 -2
- package/build/setupVitest.d.ts.map +0 -1
- package/build/setupVitest.js +0 -131
- package/build/setupVitest.js.map +0 -1
- package/src/KarmaReporterReactProfiler.js +0 -82
- package/src/chai-augmentation.d.ts +0 -8
- package/src/chaiPlugin.ts +0 -516
- package/src/components.tsx +0 -61
- package/src/createDOM.d.ts +0 -9
- package/src/createDescribe.ts +0 -31
- package/src/createRenderer.test.js +0 -31
- package/src/createRenderer.tsx +0 -809
- package/src/describeConformance.tsx +0 -1257
- package/src/describeSkipIf.tsx +0 -11
- package/src/index.ts +0 -25
- package/src/initMatchers.test.js +0 -124
- package/src/initMatchers.ts +0 -7
- package/src/initPlaywrightMatchers.ts +0 -101
- package/src/mochaHooks.js +0 -200
- package/src/mochaHooks.test.js +0 -115
- package/src/reactMajor.ts +0 -3
- package/src/setupBabel.js +0 -3
- package/src/setupBabelPlaywright.js +0 -13
- package/src/setupJSDOM.js +0 -20
- package/src/setupKarma.js +0 -65
- package/src/setupVitest.ts +0 -117
- package/tsconfig.build.json +0 -16
- 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;
|