@mui/internal-test-utils 2.0.18-canary.3 → 2.0.18-canary.30
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/LICENSE +1 -1
- package/README.md +15 -14
- package/chaiPlugin.d.mts +3 -0
- package/chaiPlugin.d.ts +1 -1
- package/chaiPlugin.js +1 -1
- package/{esm/chaiPlugin.js → chaiPlugin.mjs} +2 -2
- package/{esm/createRenderer.d.ts → createRenderer.d.mts} +11 -10
- package/createRenderer.d.ts +10 -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 +13 -11
- package/{esm/setupVitest.js → setupVitest.mjs} +16 -14
- 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/LICENSE
CHANGED
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,32 @@ You can [read the Infra documentation here](./docs/README.md).
|
|
|
9
9
|
|
|
10
10
|
## Applications
|
|
11
11
|
|
|
12
|
-
###
|
|
13
|
-
|
|
14
|
-
- Folder: `/apps/tools-public/`
|
|
15
|
-
- Hosting: https://dashboard.render.com/web/srv-d08mooq4d50c73fso49g
|
|
16
|
-
- [Docs](./apps/tools-public/#readme)
|
|
17
|
-
|
|
18
|
-
Internal public Toolpad apps that run the operations of MUI, built using https://github.com/mui/toolpad.
|
|
19
|
-
|
|
20
|
-
### [Code infra dashboard](https://frontend-public.mui.com/)
|
|
12
|
+
### Frontend Public
|
|
21
13
|
|
|
22
14
|
- URL: [frontend-public.mui.com](https://frontend-public.mui.com/)
|
|
23
|
-
-
|
|
24
|
-
- Hosting: https://
|
|
15
|
+
- Source: `/apps/code-infra-dashboard/`
|
|
16
|
+
- Hosting: https://dashboard.render.com/web/srv-d5fq2j0gjchc73e9st5g
|
|
25
17
|
- [Docs](./apps/code-infra-dashboard/#readme)
|
|
26
18
|
|
|
19
|
+
### MUI Internal
|
|
20
|
+
|
|
21
|
+
- URL: [mui-internal.netlify.app](https://mui-internal.netlify.app)
|
|
22
|
+
- Source: `/docs/`
|
|
23
|
+
- Hosting: https://app.netlify.com/projects/mui-internal/overview
|
|
24
|
+
- [Docs](./docs/#readme)
|
|
25
|
+
- Website for MUI internal packages, e.g. hosts docs-infra.
|
|
26
|
+
This is equivalent to https://backoffice.mui.com/ but for public logic.
|
|
27
|
+
|
|
27
28
|
## Packages
|
|
28
29
|
|
|
29
30
|
### [docs-infra](./packages/docs-infra/)
|
|
30
31
|
|
|
31
|
-
-
|
|
32
|
+
- Source: `/packages/docs-infra/`
|
|
32
33
|
- [Docs](./packages/docs-infra/README.md)
|
|
33
34
|
|
|
34
35
|
### [code-infra](./packages/code-infra/)
|
|
35
36
|
|
|
36
|
-
-
|
|
37
|
+
- Source: `/packages/code-infra/`
|
|
37
38
|
- [Docs](./packages/code-infra/README.md)
|
|
38
39
|
|
|
39
40
|
## Versioning
|
package/chaiPlugin.d.mts
ADDED
package/chaiPlugin.d.ts
CHANGED
package/chaiPlugin.js
CHANGED
|
@@ -231,7 +231,7 @@ const chaiPlugin = (chaiAPI, utils) => {
|
|
|
231
231
|
// unexpected thrown error takes precedence over unexpected console call
|
|
232
232
|
if (caughtError !== null) {
|
|
233
233
|
// not the same pattern as described in the block because we don't rethrow in the catch
|
|
234
|
-
// eslint-disable-next-line no-unsafe-finally
|
|
234
|
+
// eslint-disable-next-line no-unsafe-finally, mui/no-guarded-throw
|
|
235
235
|
throw caughtError;
|
|
236
236
|
}
|
|
237
237
|
const formatMessages = messages => {
|
|
@@ -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) {
|
|
@@ -224,7 +224,7 @@ const chaiPlugin = (chaiAPI, utils) => {
|
|
|
224
224
|
// unexpected thrown error takes precedence over unexpected console call
|
|
225
225
|
if (caughtError !== null) {
|
|
226
226
|
// not the same pattern as described in the block because we don't rethrow in the catch
|
|
227
|
-
// eslint-disable-next-line no-unsafe-finally
|
|
227
|
+
// eslint-disable-next-line no-unsafe-finally, mui/no-guarded-throw
|
|
228
228
|
throw caughtError;
|
|
229
229
|
}
|
|
230
230
|
const formatMessages = messages => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { queries,
|
|
1
|
+
import { queries, fireEvent as rtlFireEvent } from '@testing-library/react/pure.js';
|
|
2
|
+
import type { RenderResult, Screen, RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
2
3
|
import { userEvent } from '@testing-library/user-event';
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { flushMicrotasks } from "./flushMicrotasks.
|
|
5
|
+
import { vi } from 'vitest';
|
|
6
|
+
import { flushMicrotasks } from "./flushMicrotasks.mjs";
|
|
6
7
|
declare function queryAllDescriptionsOf(baseElement: HTMLElement, element: Element): HTMLElement[];
|
|
7
8
|
declare const customQueries: {
|
|
8
9
|
queryDescriptionOf: import("@testing-library/dom").QueryBy<[Element]>;
|
|
@@ -88,7 +89,7 @@ export interface Clock {
|
|
|
88
89
|
restore(): void;
|
|
89
90
|
}
|
|
90
91
|
export type ClockConfig = undefined | number | Date;
|
|
91
|
-
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof useFakeTimers>[0], number | Date>): Clock;
|
|
92
|
+
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof vi.useFakeTimers>[0], number | Date>): Clock;
|
|
92
93
|
export interface Renderer {
|
|
93
94
|
clock: Clock;
|
|
94
95
|
render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
|
|
@@ -160,12 +161,6 @@ declare const bodyBoundQueries: {
|
|
|
160
161
|
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
162
|
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
163
|
} & {
|
|
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
164
|
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
170
165
|
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
171
166
|
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
@@ -214,6 +209,12 @@ declare const bodyBoundQueries: {
|
|
|
214
209
|
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
215
210
|
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
211
|
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
212
|
+
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
213
|
+
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
214
|
+
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
215
|
+
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
216
|
+
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
217
|
+
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
217
218
|
};
|
|
218
219
|
export { configure, render, renderHook, waitFor, within, cleanup, createEvent, type RenderHookResult, type EventType } from '@testing-library/react/pure.js';
|
|
219
220
|
export { act, fireEvent };
|
package/createRenderer.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { queries,
|
|
1
|
+
import { queries, fireEvent as rtlFireEvent } from '@testing-library/react/pure.js';
|
|
2
|
+
import type { RenderResult, Screen, RenderOptions as TestingLibraryRenderOptions } from '@testing-library/react/pure.js';
|
|
2
3
|
import { userEvent } from '@testing-library/user-event';
|
|
3
4
|
import * as React from 'react';
|
|
4
|
-
import {
|
|
5
|
+
import { vi } from 'vitest';
|
|
5
6
|
import { flushMicrotasks } from "./flushMicrotasks.js";
|
|
6
7
|
declare function queryAllDescriptionsOf(baseElement: HTMLElement, element: Element): HTMLElement[];
|
|
7
8
|
declare const customQueries: {
|
|
@@ -88,7 +89,7 @@ export interface Clock {
|
|
|
88
89
|
restore(): void;
|
|
89
90
|
}
|
|
90
91
|
export type ClockConfig = undefined | number | Date;
|
|
91
|
-
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof useFakeTimers>[0], number | Date>): Clock;
|
|
92
|
+
declare function createClock(defaultMode: 'fake' | 'real', config: ClockConfig, options: Exclude<Parameters<typeof vi.useFakeTimers>[0], number | Date>): Clock;
|
|
92
93
|
export interface Renderer {
|
|
93
94
|
clock: Clock;
|
|
94
95
|
render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
|
|
@@ -160,12 +161,6 @@ declare const bodyBoundQueries: {
|
|
|
160
161
|
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
162
|
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
163
|
} & {
|
|
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
164
|
getByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement;
|
|
170
165
|
getAllByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement[];
|
|
171
166
|
queryByLabelText: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").SelectorMatcherOptions | undefined) => HTMLElement | null;
|
|
@@ -214,6 +209,12 @@ declare const bodyBoundQueries: {
|
|
|
214
209
|
queryAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined) => HTMLElement[];
|
|
215
210
|
findByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
216
211
|
findAllByTestId: (id: import("@testing-library/dom").Matcher, options?: import("@testing-library/dom").MatcherOptions | undefined, waitForElementOptions?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
212
|
+
queryDescriptionOf: (args_0: Element) => HTMLElement | null;
|
|
213
|
+
queryAllDescriptionsOf: (element: Element) => HTMLElement[];
|
|
214
|
+
getDescriptionOf: (args_0: Element) => HTMLElement;
|
|
215
|
+
getAllDescriptionsOf: (args_0: Element) => HTMLElement[];
|
|
216
|
+
findDescriptionOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement>;
|
|
217
|
+
findAllDescriptionsOf: (args_0: Element, args_1?: undefined, args_2?: import("@testing-library/dom").waitForOptions | undefined) => Promise<HTMLElement[]>;
|
|
217
218
|
};
|
|
218
219
|
export { configure, render, renderHook, waitFor, within, cleanup, createEvent, type RenderHookResult, type EventType } from '@testing-library/react/pure.js';
|
|
219
220
|
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,
|