@mui/internal-test-utils 2.0.18-canary.2 → 2.0.18-canary.21
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/README.md +23 -12
- package/chaiPlugin.d.mts +3 -0
- package/chaiPlugin.d.ts +1 -1
- package/{esm/chaiPlugin.js → chaiPlugin.mjs} +1 -1
- package/{esm/createRenderer.d.ts → createRenderer.d.mts} +10 -10
- package/createRenderer.d.ts +9 -9
- package/{esm/createRenderer.js → createRenderer.mjs} +3 -3
- package/{esm/describeConformance.d.ts → describeConformance.d.mts} +2 -20
- package/describeConformance.d.ts +1 -19
- package/describeConformance.js +2 -173
- package/{esm/describeConformance.js → describeConformance.mjs} +4 -175
- package/{esm/flushMicrotasks.js → flushMicrotasks.mjs} +1 -1
- package/{esm/focusVisible.js → focusVisible.mjs} +1 -1
- package/index.d.mts +11 -0
- package/index.js +2 -2
- package/index.mjs +19 -0
- package/initMatchers.d.mts +5 -0
- package/{esm/initMatchers.js → initMatchers.mjs} +2 -2
- package/{esm/initPlaywrightMatchers.d.ts → initPlaywrightMatchers.d.mts} +1 -1
- package/initPlaywrightMatchers.d.ts +1 -1
- package/package.json +57 -27
- package/{esm/setupVitest.d.ts → setupVitest.d.mts} +2 -2
- package/setupVitest.d.ts +1 -1
- package/setupVitest.js +11 -9
- package/{esm/setupVitest.js → setupVitest.mjs} +14 -12
- package/esm/chaiPlugin.d.ts +0 -3
- package/esm/index.d.ts +0 -11
- package/esm/index.js +0 -19
- package/esm/initMatchers.d.ts +0 -5
- package/esm/package.json +0 -1
- /package/{esm/chaiTypes.d.ts → chaiTypes.d.mts} +0 -0
- /package/{esm/chaiTypes.js → chaiTypes.mjs} +0 -0
- /package/{esm/components.d.ts → components.d.mts} +0 -0
- /package/{esm/components.js → components.mjs} +0 -0
- /package/{esm/configure.d.ts → configure.d.mts} +0 -0
- /package/{esm/configure.js → configure.mjs} +0 -0
- /package/{esm/createDescribe.d.ts → createDescribe.d.mts} +0 -0
- /package/{esm/createDescribe.js → createDescribe.mjs} +0 -0
- /package/{esm/env.d.ts → env.d.mts} +0 -0
- /package/{esm/env.js → env.mjs} +0 -0
- /package/{esm/flushMicrotasks.d.ts → flushMicrotasks.d.mts} +0 -0
- /package/{esm/focusVisible.d.ts → focusVisible.d.mts} +0 -0
- /package/{esm/ignoreActWarnings.d.ts → ignoreActWarnings.d.mts} +0 -0
- /package/{esm/ignoreActWarnings.js → ignoreActWarnings.mjs} +0 -0
- /package/{esm/initPlaywrightMatchers.js → initPlaywrightMatchers.mjs} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MUI Public
|
|
2
2
|
|
|
3
|
-
Mono-repository for the MUI organization with code that can be public
|
|
3
|
+
Mono-repository for the MUI organization with code that can be public.\
|
|
4
4
|
See https://github.com/mui/mui-private for code that needs to be private.
|
|
5
5
|
|
|
6
6
|
## Documentation
|
|
@@ -9,31 +9,42 @@ You can [read the Infra documentation here](./docs/README.md).
|
|
|
9
9
|
|
|
10
10
|
## Applications
|
|
11
11
|
|
|
12
|
-
###
|
|
12
|
+
### Frontend Public
|
|
13
13
|
|
|
14
|
-
-
|
|
14
|
+
- URL: [frontend-public.mui.com](https://frontend-public.mui.com/)
|
|
15
|
+
- Source: `/apps/code-infra-dashboard/`
|
|
16
|
+
- Hosting: https://dashboard.render.com/web/srv-d5fq2j0gjchc73e9st5g
|
|
17
|
+
- [Docs](./apps/code-infra-dashboard/#readme)
|
|
18
|
+
|
|
19
|
+
### Tools Public
|
|
20
|
+
|
|
21
|
+
⚠️ Deprecated. Use **Frontend Public** instead.
|
|
22
|
+
|
|
23
|
+
- URL: [tools-public.mui.com](https://tools-public.mui.com/)
|
|
24
|
+
- Source: `/apps/tools-public/`
|
|
15
25
|
- Hosting: https://dashboard.render.com/web/srv-d08mooq4d50c73fso49g
|
|
16
26
|
- [Docs](./apps/tools-public/#readme)
|
|
27
|
+
- Internal public Toolpad apps that run the operations of MUI, built using https://github.com/mui/toolpad.
|
|
17
28
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### [Code infra dashboard](https://frontend-public.mui.com/)
|
|
29
|
+
### MUI Internal
|
|
21
30
|
|
|
22
|
-
- URL: [
|
|
23
|
-
-
|
|
24
|
-
- Hosting: https://app.netlify.com/
|
|
25
|
-
- [Docs](./
|
|
31
|
+
- URL: [mui-internal.netlify.app](https://mui-internal.netlify.app)
|
|
32
|
+
- Source: `/docs/`
|
|
33
|
+
- Hosting: https://app.netlify.com/projects/mui-internal/overview
|
|
34
|
+
- [Docs](./docs/#readme)
|
|
35
|
+
- Website for MUI internal packages, e.g. hosts docs-infra.
|
|
36
|
+
This is equivalent to https://backoffice.mui.com/ but for public logic.
|
|
26
37
|
|
|
27
38
|
## Packages
|
|
28
39
|
|
|
29
40
|
### [docs-infra](./packages/docs-infra/)
|
|
30
41
|
|
|
31
|
-
-
|
|
42
|
+
- Source: `/packages/docs-infra/`
|
|
32
43
|
- [Docs](./packages/docs-infra/README.md)
|
|
33
44
|
|
|
34
45
|
### [code-infra](./packages/code-infra/)
|
|
35
46
|
|
|
36
|
-
-
|
|
47
|
+
- Source: `/packages/code-infra/`
|
|
37
48
|
- [Docs](./packages/code-infra/README.md)
|
|
38
49
|
|
|
39
50
|
## Versioning
|
package/chaiPlugin.d.mts
ADDED
package/chaiPlugin.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { computeAccessibleDescription, computeAccessibleName } from 'dom-accessi
|
|
|
5
5
|
import formatUtil from 'format-util';
|
|
6
6
|
import { kebabCase } from 'es-toolkit/string';
|
|
7
7
|
import { AssertionError } from 'assertion-error';
|
|
8
|
-
import { isJsdom } from "./env.
|
|
8
|
+
import { isJsdom } from "./env.mjs";
|
|
9
9
|
|
|
10
10
|
// chai#utils.elToString that looks like stringified elements in testing-library
|
|
11
11
|
function elementToString(element) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { queries, RenderResult, fireEvent as rtlFireEvent, Screen, RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
1
|
+
import { queries, type RenderResult, fireEvent as rtlFireEvent, type Screen, type RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
2
2
|
import { userEvent } from '@testing-library/user-event';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { flushMicrotasks } from "./flushMicrotasks.
|
|
4
|
+
import { vi } from 'vitest';
|
|
5
|
+
import { flushMicrotasks } from "./flushMicrotasks.mjs";
|
|
6
6
|
declare function queryAllDescriptionsOf(baseElement: HTMLElement, element: Element): HTMLElement[];
|
|
7
7
|
declare const customQueries: {
|
|
8
8
|
queryDescriptionOf: import("@testing-library/dom").QueryBy<[Element]>;
|
|
@@ -88,7 +88,7 @@ export interface Clock {
|
|
|
88
88
|
restore(): void;
|
|
89
89
|
}
|
|
90
90
|
export type ClockConfig = undefined | number | Date;
|
|
91
|
-
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof useFakeTimers>[0], number | Date>): Clock;
|
|
91
|
+
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof vi.useFakeTimers>[0], number | Date>): Clock;
|
|
92
92
|
export interface Renderer {
|
|
93
93
|
clock: Clock;
|
|
94
94
|
render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
|
|
@@ -160,12 +160,6 @@ declare const bodyBoundQueries: {
|
|
|
160
160
|
findByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
|
|
161
161
|
findAllByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
|
|
162
162
|
} & {
|
|
163
|
-
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
164
|
-
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
165
|
-
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
166
|
-
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
167
|
-
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
168
|
-
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
169
163
|
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
170
164
|
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
171
165
|
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
@@ -214,6 +208,12 @@ declare const bodyBoundQueries: {
|
|
|
214
208
|
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
215
209
|
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
210
|
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
211
|
+
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
212
|
+
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
213
|
+
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
214
|
+
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
215
|
+
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
|
+
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
217
217
|
};
|
|
218
218
|
export { configure, render, renderHook, waitFor, within, cleanup, createEvent, type RenderHookResult, type EventType } from '@testing-library/react/pure.js';
|
|
219
219
|
export { act, fireEvent };
|
package/createRenderer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { queries, RenderResult, fireEvent as rtlFireEvent, Screen, RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
1
|
+
import { queries, type RenderResult, fireEvent as rtlFireEvent, type Screen, type RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
2
2
|
import { userEvent } from '@testing-library/user-event';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { vi } from 'vitest';
|
|
5
5
|
import { flushMicrotasks } from "./flushMicrotasks.js";
|
|
6
6
|
declare function queryAllDescriptionsOf(baseElement: HTMLElement, element: Element): HTMLElement[];
|
|
7
7
|
declare const customQueries: {
|
|
@@ -88,7 +88,7 @@ export interface Clock {
|
|
|
88
88
|
restore(): void;
|
|
89
89
|
}
|
|
90
90
|
export type ClockConfig = undefined | number | Date;
|
|
91
|
-
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof useFakeTimers>[0], number | Date>): Clock;
|
|
91
|
+
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof vi.useFakeTimers>[0], number | Date>): Clock;
|
|
92
92
|
export interface Renderer {
|
|
93
93
|
clock: Clock;
|
|
94
94
|
render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
|
|
@@ -160,12 +160,6 @@ declare const bodyBoundQueries: {
|
|
|
160
160
|
findByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): ReturnType<queries.FindByBoundAttribute<T>>;
|
|
161
161
|
findAllByTestId<T extends HTMLElement = HTMLElement>(id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined): ReturnType<queries.FindAllByBoundAttribute<T>>;
|
|
162
162
|
} & {
|
|
163
|
-
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
164
|
-
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
165
|
-
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
166
|
-
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
167
|
-
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
168
|
-
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
169
163
|
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
170
164
|
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
171
165
|
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
@@ -214,6 +208,12 @@ declare const bodyBoundQueries: {
|
|
|
214
208
|
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
215
209
|
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
210
|
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
211
|
+
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
212
|
+
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
213
|
+
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
214
|
+
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
215
|
+
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
|
+
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
217
217
|
};
|
|
218
218
|
export { configure, render, renderHook, waitFor, within, cleanup, createEvent, type RenderHookResult, type EventType } from '@testing-library/react/pure.js';
|
|
219
219
|
export { act, fireEvent };
|
|
@@ -5,9 +5,9 @@ import { userEvent } from '@testing-library/user-event';
|
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import * as ReactDOMServer from 'react-dom/server';
|
|
7
7
|
import { beforeEach, afterEach, beforeAll, vi } from 'vitest';
|
|
8
|
-
import { reactMajor } from "./env.
|
|
9
|
-
import { flushMicrotasks } from "./flushMicrotasks.
|
|
10
|
-
import { config as utilsConfig } from "./configure.
|
|
8
|
+
import { reactMajor } from "./env.mjs";
|
|
9
|
+
import { flushMicrotasks } from "./flushMicrotasks.mjs";
|
|
10
|
+
import { config as utilsConfig } from "./configure.mjs";
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function queryAllDescriptionsOf(baseElement, element) {
|
|
13
13
|
const ariaDescribedBy = element.getAttribute('aria-describedby');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { MuiRenderResult } from "./createRenderer.
|
|
2
|
+
import { type MuiRenderResult } from "./createRenderer.mjs";
|
|
3
3
|
interface DataProps {
|
|
4
4
|
[key: `data-${string}`]: string;
|
|
5
5
|
}
|
|
@@ -59,7 +59,6 @@ export interface ConformanceOptions {
|
|
|
59
59
|
};
|
|
60
60
|
testCustomVariant?: boolean;
|
|
61
61
|
testVariantProps?: object;
|
|
62
|
-
testLegacyComponentsProp?: boolean | string[];
|
|
63
62
|
slots?: Record<string, SlotTestingOptions>;
|
|
64
63
|
ThemeProvider?: React.ElementType;
|
|
65
64
|
/**
|
|
@@ -123,20 +122,11 @@ declare function testSlotsProp(element: React.ReactElement<{
|
|
|
123
122
|
children: React.ReactNode;
|
|
124
123
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
125
124
|
};
|
|
126
|
-
components?: {
|
|
127
|
-
[x: string]: SlotTestingOptions['testWithComponent'] | keyof React.JSX.IntrinsicElements | React.ForwardRefExoticComponent<{
|
|
128
|
-
children: React.ReactNode;
|
|
129
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
130
|
-
};
|
|
131
125
|
slotProps: {
|
|
132
126
|
[x: string]: DataProps;
|
|
133
127
|
};
|
|
134
|
-
componentsProps?: {
|
|
135
|
-
[x: string]: DataProps;
|
|
136
|
-
};
|
|
137
128
|
}>, getOptions: () => ConformanceOptions): void;
|
|
138
129
|
declare function testSlotPropsProp(element: React.ReactElement<{
|
|
139
|
-
componentsProps?: Record<string, DataProps>;
|
|
140
130
|
slotProps: Record<string, DataProps>;
|
|
141
131
|
}>, getOptions: () => ConformanceOptions): void;
|
|
142
132
|
declare function testSlotPropsCallback(element: React.ReactElement<{
|
|
@@ -147,13 +137,6 @@ declare function testSlotPropsCallbackWithPropsAsOwnerState(element: React.React
|
|
|
147
137
|
slotProps: Record<string, (ownerState: Record<string, any>) => DataProps>;
|
|
148
138
|
className: string;
|
|
149
139
|
}>, 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
140
|
/**
|
|
158
141
|
* MUI theme has a components section that allows specifying default props.
|
|
159
142
|
* Components from @inheritComponent
|
|
@@ -178,7 +161,6 @@ declare function testThemeVariants(element: React.ReactElement<DataProps & {
|
|
|
178
161
|
declare function testThemeCustomPalette(element: React.ReactElement<unknown>, getOptions: () => ConformanceOptions): void;
|
|
179
162
|
declare const fullSuite: {
|
|
180
163
|
componentProp: typeof testComponentProp;
|
|
181
|
-
componentsProp: typeof testComponentsProp;
|
|
182
164
|
mergeClassName: typeof testClassName;
|
|
183
165
|
propsSpread: typeof testPropsSpread;
|
|
184
166
|
refForwarding: typeof describeRef;
|
|
@@ -192,5 +174,5 @@ declare const fullSuite: {
|
|
|
192
174
|
themeVariants: typeof testThemeVariants;
|
|
193
175
|
themeCustomPalette: typeof testThemeCustomPalette;
|
|
194
176
|
};
|
|
195
|
-
declare const _default: import("./createDescribe.
|
|
177
|
+
declare const _default: import("./createDescribe.mjs").MUIDescribe<[minimalElement: React.ReactElement<any, string | React.JSXElementConstructor<any>>, getOptions: () => ConformanceOptions]>;
|
|
196
178
|
export default _default;
|
package/describeConformance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { MuiRenderResult } from "./createRenderer.js";
|
|
2
|
+
import { type MuiRenderResult } from "./createRenderer.js";
|
|
3
3
|
interface DataProps {
|
|
4
4
|
[key: `data-${string}`]: string;
|
|
5
5
|
}
|
|
@@ -59,7 +59,6 @@ export interface ConformanceOptions {
|
|
|
59
59
|
};
|
|
60
60
|
testCustomVariant?: boolean;
|
|
61
61
|
testVariantProps?: object;
|
|
62
|
-
testLegacyComponentsProp?: boolean | string[];
|
|
63
62
|
slots?: Record<string, SlotTestingOptions>;
|
|
64
63
|
ThemeProvider?: React.ElementType;
|
|
65
64
|
/**
|
|
@@ -123,20 +122,11 @@ declare function testSlotsProp(element: React.ReactElement<{
|
|
|
123
122
|
children: React.ReactNode;
|
|
124
123
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
125
124
|
};
|
|
126
|
-
components?: {
|
|
127
|
-
[x: string]: SlotTestingOptions['testWithComponent'] | keyof React.JSX.IntrinsicElements | React.ForwardRefExoticComponent<{
|
|
128
|
-
children: React.ReactNode;
|
|
129
|
-
} & React.RefAttributes<HTMLDivElement>>;
|
|
130
|
-
};
|
|
131
125
|
slotProps: {
|
|
132
126
|
[x: string]: DataProps;
|
|
133
127
|
};
|
|
134
|
-
componentsProps?: {
|
|
135
|
-
[x: string]: DataProps;
|
|
136
|
-
};
|
|
137
128
|
}>, getOptions: () => ConformanceOptions): void;
|
|
138
129
|
declare function testSlotPropsProp(element: React.ReactElement<{
|
|
139
|
-
componentsProps?: Record<string, DataProps>;
|
|
140
130
|
slotProps: Record<string, DataProps>;
|
|
141
131
|
}>, getOptions: () => ConformanceOptions): void;
|
|
142
132
|
declare function testSlotPropsCallback(element: React.ReactElement<{
|
|
@@ -147,13 +137,6 @@ declare function testSlotPropsCallbackWithPropsAsOwnerState(element: React.React
|
|
|
147
137
|
slotProps: Record<string, (ownerState: Record<string, any>) => DataProps>;
|
|
148
138
|
className: string;
|
|
149
139
|
}>, 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
140
|
/**
|
|
158
141
|
* MUI theme has a components section that allows specifying default props.
|
|
159
142
|
* Components from @inheritComponent
|
|
@@ -178,7 +161,6 @@ declare function testThemeVariants(element: React.ReactElement<DataProps & {
|
|
|
178
161
|
declare function testThemeCustomPalette(element: React.ReactElement<unknown>, getOptions: () => ConformanceOptions): void;
|
|
179
162
|
declare const fullSuite: {
|
|
180
163
|
componentProp: typeof testComponentProp;
|
|
181
|
-
componentsProp: typeof testComponentsProp;
|
|
182
164
|
mergeClassName: typeof testClassName;
|
|
183
165
|
propsSpread: typeof testPropsSpread;
|
|
184
166
|
refForwarding: typeof describeRef;
|
package/describeConformance.js
CHANGED
|
@@ -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.
|
|
5
|
-
import { isJsdom } from "./env.
|
|
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,
|
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
|
|
5
|
-
* This source code is licensed under 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";
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-test-utils",
|
|
3
|
-
"version": "2.0.18-canary.
|
|
3
|
+
"version": "2.0.18-canary.21",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Utilities for MUI tests. This is an internal package not meant for general use.",
|
|
6
|
+
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/mui/mui-public.git",
|
|
@@ -10,18 +11,16 @@
|
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"@types/chai-dom": "^1.11.3",
|
|
13
|
-
"@babel/runtime": "^7.
|
|
14
|
+
"@babel/runtime": "^7.29.2",
|
|
14
15
|
"@testing-library/dom": "^10.4.1",
|
|
15
|
-
"@testing-library/react": "^16.3.
|
|
16
|
+
"@testing-library/react": "^16.3.2",
|
|
16
17
|
"@testing-library/user-event": "^14.6.1",
|
|
17
18
|
"assertion-error": "^2.0.1",
|
|
18
19
|
"chai-dom": "^1.12.1",
|
|
19
20
|
"dom-accessibility-api": "^0.7.1",
|
|
20
|
-
"es-toolkit": "^1.
|
|
21
|
+
"es-toolkit": "^1.45.1",
|
|
21
22
|
"format-util": "^1.0.5",
|
|
22
|
-
"jsdom": "^26.1.0",
|
|
23
23
|
"prop-types": "^15.8.1",
|
|
24
|
-
"sinon": "^21.0.1",
|
|
25
24
|
"vitest-fail-on-console": "^0.10.1"
|
|
26
25
|
},
|
|
27
26
|
"peerDependencies": {
|
|
@@ -44,91 +43,122 @@
|
|
|
44
43
|
"access": "public"
|
|
45
44
|
},
|
|
46
45
|
"type": "commonjs",
|
|
47
|
-
"main": "./index.js",
|
|
48
|
-
"types": "./index.d.ts",
|
|
49
46
|
"exports": {
|
|
50
47
|
"./package.json": "./package.json",
|
|
51
48
|
".": {
|
|
49
|
+
"import": {
|
|
50
|
+
"types": "./index.d.mts",
|
|
51
|
+
"default": "./index.mjs"
|
|
52
|
+
},
|
|
52
53
|
"require": {
|
|
53
54
|
"types": "./index.d.ts",
|
|
54
55
|
"default": "./index.js"
|
|
55
56
|
},
|
|
56
57
|
"default": {
|
|
57
|
-
"types": "./
|
|
58
|
-
"default": "./
|
|
58
|
+
"types": "./index.d.mts",
|
|
59
|
+
"default": "./index.mjs"
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
62
|
"./createDescribe": {
|
|
63
|
+
"import": {
|
|
64
|
+
"types": "./createDescribe.d.mts",
|
|
65
|
+
"default": "./createDescribe.mjs"
|
|
66
|
+
},
|
|
62
67
|
"require": {
|
|
63
68
|
"types": "./createDescribe.d.ts",
|
|
64
69
|
"default": "./createDescribe.js"
|
|
65
70
|
},
|
|
66
71
|
"default": {
|
|
67
|
-
"types": "./
|
|
68
|
-
"default": "./
|
|
72
|
+
"types": "./createDescribe.d.mts",
|
|
73
|
+
"default": "./createDescribe.mjs"
|
|
69
74
|
}
|
|
70
75
|
},
|
|
71
76
|
"./createRenderer": {
|
|
77
|
+
"import": {
|
|
78
|
+
"types": "./createRenderer.d.mts",
|
|
79
|
+
"default": "./createRenderer.mjs"
|
|
80
|
+
},
|
|
72
81
|
"require": {
|
|
73
82
|
"types": "./createRenderer.d.ts",
|
|
74
83
|
"default": "./createRenderer.js"
|
|
75
84
|
},
|
|
76
85
|
"default": {
|
|
77
|
-
"types": "./
|
|
78
|
-
"default": "./
|
|
86
|
+
"types": "./createRenderer.d.mts",
|
|
87
|
+
"default": "./createRenderer.mjs"
|
|
79
88
|
}
|
|
80
89
|
},
|
|
81
90
|
"./initMatchers": {
|
|
91
|
+
"import": {
|
|
92
|
+
"types": "./initMatchers.d.mts",
|
|
93
|
+
"default": "./initMatchers.mjs"
|
|
94
|
+
},
|
|
82
95
|
"require": {
|
|
83
96
|
"types": "./initMatchers.d.ts",
|
|
84
97
|
"default": "./initMatchers.js"
|
|
85
98
|
},
|
|
86
99
|
"default": {
|
|
87
|
-
"types": "./
|
|
88
|
-
"default": "./
|
|
100
|
+
"types": "./initMatchers.d.mts",
|
|
101
|
+
"default": "./initMatchers.mjs"
|
|
89
102
|
}
|
|
90
103
|
},
|
|
91
104
|
"./env": {
|
|
105
|
+
"import": {
|
|
106
|
+
"types": "./env.d.mts",
|
|
107
|
+
"default": "./env.mjs"
|
|
108
|
+
},
|
|
92
109
|
"require": {
|
|
93
110
|
"types": "./env.d.ts",
|
|
94
111
|
"default": "./env.js"
|
|
95
112
|
},
|
|
96
113
|
"default": {
|
|
97
|
-
"types": "./
|
|
98
|
-
"default": "./
|
|
114
|
+
"types": "./env.d.mts",
|
|
115
|
+
"default": "./env.mjs"
|
|
99
116
|
}
|
|
100
117
|
},
|
|
101
118
|
"./initPlaywrightMatchers": {
|
|
119
|
+
"import": {
|
|
120
|
+
"types": "./initPlaywrightMatchers.d.mts",
|
|
121
|
+
"default": "./initPlaywrightMatchers.mjs"
|
|
122
|
+
},
|
|
102
123
|
"require": {
|
|
103
124
|
"types": "./initPlaywrightMatchers.d.ts",
|
|
104
125
|
"default": "./initPlaywrightMatchers.js"
|
|
105
126
|
},
|
|
106
127
|
"default": {
|
|
107
|
-
"types": "./
|
|
108
|
-
"default": "./
|
|
128
|
+
"types": "./initPlaywrightMatchers.d.mts",
|
|
129
|
+
"default": "./initPlaywrightMatchers.mjs"
|
|
109
130
|
}
|
|
110
131
|
},
|
|
111
132
|
"./chaiPlugin": {
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./chaiPlugin.d.mts",
|
|
135
|
+
"default": "./chaiPlugin.mjs"
|
|
136
|
+
},
|
|
112
137
|
"require": {
|
|
113
138
|
"types": "./chaiPlugin.d.ts",
|
|
114
139
|
"default": "./chaiPlugin.js"
|
|
115
140
|
},
|
|
116
141
|
"default": {
|
|
117
|
-
"types": "./
|
|
118
|
-
"default": "./
|
|
142
|
+
"types": "./chaiPlugin.d.mts",
|
|
143
|
+
"default": "./chaiPlugin.mjs"
|
|
119
144
|
}
|
|
120
145
|
},
|
|
121
146
|
"./setupVitest": {
|
|
147
|
+
"import": {
|
|
148
|
+
"types": "./setupVitest.d.mts",
|
|
149
|
+
"default": "./setupVitest.mjs"
|
|
150
|
+
},
|
|
122
151
|
"require": {
|
|
123
152
|
"types": "./setupVitest.d.ts",
|
|
124
153
|
"default": "./setupVitest.js"
|
|
125
154
|
},
|
|
126
155
|
"default": {
|
|
127
|
-
"types": "./
|
|
128
|
-
"default": "./
|
|
156
|
+
"types": "./setupVitest.d.mts",
|
|
157
|
+
"default": "./setupVitest.mjs"
|
|
129
158
|
}
|
|
130
|
-
}
|
|
131
|
-
"./esm": null
|
|
159
|
+
}
|
|
132
160
|
},
|
|
133
|
-
"
|
|
161
|
+
"main": "./index.js",
|
|
162
|
+
"types": "./index.d.ts",
|
|
163
|
+
"gitSha": "b5ecb08ed447855ed858e123d924a08949b6ad6d"
|
|
134
164
|
}
|
package/setupVitest.d.ts
CHANGED
package/setupVitest.js
CHANGED
|
@@ -36,15 +36,6 @@ function setupVitest({
|
|
|
36
36
|
_vitest.vi.useRealTimers();
|
|
37
37
|
(0, _pure.cleanup)();
|
|
38
38
|
});
|
|
39
|
-
if (isInitialized) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
(0, _configure.configure)(config);
|
|
43
|
-
isInitialized = true;
|
|
44
|
-
|
|
45
|
-
// Don't call test lifecycle hooks after this point
|
|
46
|
-
|
|
47
|
-
chai.use(_chaiPlugin.default);
|
|
48
39
|
if (failOnConsoleEnabled) {
|
|
49
40
|
(0, _vitestFailOnConsole.default)({
|
|
50
41
|
silenceMessage: message => {
|
|
@@ -70,6 +61,17 @@ function setupVitest({
|
|
|
70
61
|
}
|
|
71
62
|
});
|
|
72
63
|
}
|
|
64
|
+
|
|
65
|
+
// Don't call test lifecycle hooks (afterEach/afterAll/beforeEach/beforeAll/...) after this point
|
|
66
|
+
// Make sure none of (transitive) dependencies call lifecycle hooks either, otherwise they won't be
|
|
67
|
+
// registered and thus won't run when using `--no-isolate --no-file-parallelism`.
|
|
68
|
+
|
|
69
|
+
if (isInitialized) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
isInitialized = true;
|
|
73
|
+
(0, _configure.configure)(config);
|
|
74
|
+
chai.use(_chaiPlugin.default);
|
|
73
75
|
if (typeof window !== 'undefined') {
|
|
74
76
|
chai.use(_chaiDom.default);
|
|
75
77
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import failOnConsole from 'vitest-fail-on-console';
|
|
2
2
|
import * as chai from 'chai';
|
|
3
|
-
import "./chaiTypes.
|
|
3
|
+
import "./chaiTypes.mjs";
|
|
4
4
|
// eslint-disable-next-line import/extensions
|
|
5
5
|
import { cleanup, act } from '@testing-library/react/pure.js';
|
|
6
6
|
import { afterEach, vi } from 'vitest';
|
|
7
7
|
import chaiDom from 'chai-dom';
|
|
8
|
-
import chaiPlugin from "./chaiPlugin.
|
|
9
|
-
import { configure } from "./configure.
|
|
8
|
+
import chaiPlugin from "./chaiPlugin.mjs";
|
|
9
|
+
import { configure } from "./configure.mjs";
|
|
10
10
|
let isInitialized = false;
|
|
11
11
|
export default function setupVitest({
|
|
12
12
|
failOnConsoleEnabled = true,
|
|
@@ -27,15 +27,6 @@ export default function setupVitest({
|
|
|
27
27
|
vi.useRealTimers();
|
|
28
28
|
cleanup();
|
|
29
29
|
});
|
|
30
|
-
if (isInitialized) {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
configure(config);
|
|
34
|
-
isInitialized = true;
|
|
35
|
-
|
|
36
|
-
// Don't call test lifecycle hooks after this point
|
|
37
|
-
|
|
38
|
-
chai.use(chaiPlugin);
|
|
39
30
|
if (failOnConsoleEnabled) {
|
|
40
31
|
failOnConsole({
|
|
41
32
|
silenceMessage: message => {
|
|
@@ -61,6 +52,17 @@ export default function setupVitest({
|
|
|
61
52
|
}
|
|
62
53
|
});
|
|
63
54
|
}
|
|
55
|
+
|
|
56
|
+
// Don't call test lifecycle hooks (afterEach/afterAll/beforeEach/beforeAll/...) after this point
|
|
57
|
+
// Make sure none of (transitive) dependencies call lifecycle hooks either, otherwise they won't be
|
|
58
|
+
// registered and thus won't run when using `--no-isolate --no-file-parallelism`.
|
|
59
|
+
|
|
60
|
+
if (isInitialized) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
isInitialized = true;
|
|
64
|
+
configure(config);
|
|
65
|
+
chai.use(chaiPlugin);
|
|
64
66
|
if (typeof window !== 'undefined') {
|
|
65
67
|
chai.use(chaiDom);
|
|
66
68
|
|
package/esm/chaiPlugin.d.ts
DELETED
package/esm/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import "./initMatchers.js";
|
|
2
|
-
export * from "./components.js";
|
|
3
|
-
export { default as describeConformance } from "./describeConformance.js";
|
|
4
|
-
export * from "./describeConformance.js";
|
|
5
|
-
export { default as createDescribe } from "./createDescribe.js";
|
|
6
|
-
export * from "./createRenderer.js";
|
|
7
|
-
export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
|
|
8
|
-
export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
|
|
9
|
-
export { flushMicrotasks } from "./flushMicrotasks.js";
|
|
10
|
-
export * from "./env.js";
|
|
11
|
-
export { ignoreActWarnings } from "./ignoreActWarnings.js";
|
package/esm/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @mui/internal-test-utils v2.0.17
|
|
3
|
-
*
|
|
4
|
-
* @license undefined
|
|
5
|
-
* This source code is licensed under the undefined license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
import "./initMatchers.js";
|
|
9
|
-
export * from "./components.js";
|
|
10
|
-
export { default as describeConformance } from "./describeConformance.js";
|
|
11
|
-
export * from "./describeConformance.js";
|
|
12
|
-
export { default as createDescribe } from "./createDescribe.js";
|
|
13
|
-
export * from "./createRenderer.js";
|
|
14
|
-
export { default as focusVisible, simulatePointerDevice, simulateKeyboardDevice, programmaticFocusTriggersFocusVisible } from "./focusVisible.js";
|
|
15
|
-
// eslint-disable-next-line import/extensions
|
|
16
|
-
export { fireEvent as fireDiscreteEvent } from '@testing-library/react/pure.js';
|
|
17
|
-
export { flushMicrotasks } from "./flushMicrotasks.js";
|
|
18
|
-
export * from "./env.js";
|
|
19
|
-
export { ignoreActWarnings } from "./ignoreActWarnings.js";
|
package/esm/initMatchers.d.ts
DELETED
package/esm/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module","sideEffects":false}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{esm/env.js → env.mjs}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|