Skip to content

Commit 37340ed

Browse files
committed
fix
1 parent b269f20 commit 37340ed

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

packages-internal/test-utils/src/describeConformance.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function throwMissingPropError(field: string): never {
9191
* the root component.
9292
*/
9393
export function testClassName(
94-
element: React.ReactElement<HTMLElement & { 'data-testid': string }>,
94+
element: React.ReactElement<HTMLElement & { 'data-testid'?: string }>,
9595
getOptions: () => ConformanceOptions,
9696
) {
9797
it('applies the className to the root component', async () => {
@@ -120,7 +120,7 @@ export function testComponentProp(
120120
element: React.ReactElement<
121121
HTMLElement & {
122122
component?: string | ((props: {}) => React.ReactElement);
123-
'data-testid': string;
123+
'data-testid'?: string;
124124
}
125125
>,
126126
getOptions: () => ConformanceOptions,
@@ -158,7 +158,12 @@ export function testComponentProp(
158158
* MUI components spread additional props to its root.
159159
*/
160160
export function testPropsSpread(
161-
element: React.ReactElement<HTMLElement & { [key: `data-${string}`]: string }>,
161+
element: React.ReactElement<
162+
HTMLElement & {
163+
'data-testid'?: string;
164+
'data-test-props-spread'?: string;
165+
}
166+
>,
162167
getOptions: () => ConformanceOptions,
163168
) {
164169
it(`spreads props to the root component`, async () => {
@@ -213,7 +218,7 @@ export function describeRef(
213218
* Tests that the root component has the root class
214219
*/
215220
export function testRootClass(
216-
element: React.ReactElement<HTMLElement & { classes: Record<string, string> }>,
221+
element: React.ReactElement<HTMLElement & { classes?: Record<string, string> }>,
217222
getOptions: () => ConformanceOptions,
218223
) {
219224
it('applies the root class to the root component if it has this class', async () => {
@@ -267,12 +272,13 @@ function forEachSlot(
267272

268273
function testSlotsProp(
269274
element: React.ReactElement<
270-
HTMLElement & {
271-
slots: Record<string, any>;
272-
slotProps: Record<string, any>;
273-
components: Record<string, any>;
274-
componentsProps: Record<string, any>;
275-
}
275+
HTMLElement &
276+
Partial<{
277+
slots: Record<string, any>;
278+
slotProps: Record<string, any>;
279+
components: Record<string, any>;
280+
componentsProps: Record<string, any>;
281+
}>
276282
>,
277283
getOptions: () => ConformanceOptions,
278284
) {
@@ -448,7 +454,7 @@ function testSlotsProp(
448454

449455
function testSlotPropsProp(
450456
element: React.ReactElement<
451-
HTMLElement & { slotProps: Record<string, any>; componentsProps: Record<string, any> }
457+
HTMLElement & { slotProps?: Record<string, any>; componentsProps?: Record<string, any> }
452458
>,
453459
getOptions: () => ConformanceOptions,
454460
) {
@@ -535,7 +541,7 @@ function testSlotPropsProp(
535541
}
536542

537543
function testSlotPropsCallback(
538-
element: React.ReactElement<HTMLElement & { slotProps: Record<string, any> }>,
544+
element: React.ReactElement<HTMLElement & { slotProps?: Record<string, any> }>,
539545
getOptions: () => ConformanceOptions,
540546
) {
541547
const { render, slots } = getOptions();
@@ -567,7 +573,7 @@ function testSlotPropsCallback(
567573
*/
568574
function testComponentsProp(
569575
element: React.ReactElement<
570-
HTMLElement & { components: Record<string, any>; 'data-testid': string }
576+
HTMLElement & { components?: Record<string, any>; 'data-testid'?: string }
571577
>,
572578
getOptions: () => ConformanceOptions,
573579
) {
@@ -887,7 +893,7 @@ function testThemeStyleOverrides(
887893
* Components from @inheritComponent
888894
*/
889895
function testThemeVariants(
890-
element: React.ReactElement<HTMLElement & { 'data-testid': string; variant: string }>,
896+
element: React.ReactElement<HTMLElement & { 'data-testid'?: string; variant?: string }>,
891897
getOptions: () => ConformanceOptions,
892898
) {
893899
describe('theme variants:', () => {
@@ -1040,7 +1046,7 @@ const fullSuite = {
10401046
* components.
10411047
*/
10421048
function describeConformance(
1043-
minimalElement: React.ReactElement<HTMLElement>,
1049+
minimalElement: React.ReactElement<HTMLElement & { 'data-testid': string }>,
10441050
getOptions: () => ConformanceOptions,
10451051
) {
10461052
let originalMatchmedia: typeof window.matchMedia;

0 commit comments

Comments
 (0)