From 1262b2a1563a9e79fe28375cbff5044670efa006 Mon Sep 17 00:00:00 2001 From: sai chand <60743144+sai6855@users.noreply.github.com> Date: Tue, 3 Dec 2024 21:24:21 +0530 Subject: [PATCH] [test-utils] Remove leftover React.ReactElement from describeConformance.tsx (#44639) --- .../test-utils/src/describeConformance.tsx | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/packages-internal/test-utils/src/describeConformance.tsx b/packages-internal/test-utils/src/describeConformance.tsx index 2270bac2bd461e..2cd9d11010c56b 100644 --- a/packages-internal/test-utils/src/describeConformance.tsx +++ b/packages-internal/test-utils/src/describeConformance.tsx @@ -45,7 +45,7 @@ export interface ConformanceOptions { refInstanceof: any; after?: () => void; inheritComponent?: React.ElementType; - render: (node: React.ReactElement) => MuiRenderResult | Promise; + render: (node: React.ReactElement) => MuiRenderResult | Promise; only?: Array; skip?: Array; testComponentsRootPropWith?: string; @@ -495,7 +495,13 @@ function testSlotsProp( }); } -function testSlotPropsProp(element: React.ReactElement, getOptions: () => ConformanceOptions) { +function testSlotPropsProp( + element: React.ReactElement<{ + componentsProps?: Record; + slotProps: Record; + }>, + getOptions: () => ConformanceOptions, +) { const { render, slots, testLegacyComponentsProp } = getOptions(); if (!render) { @@ -579,7 +585,10 @@ function testSlotPropsProp(element: React.ReactElement, getOptions: () => C } function testSlotPropsCallback( - element: React.ReactElement, + element: React.ReactElement<{ + slotProps: Record DataProps>; + className: string; + }>, getOptions: () => ConformanceOptions, ) { const { render, slots } = getOptions(); @@ -606,7 +615,10 @@ function testSlotPropsCallback( } function testSlotPropsCallbackWithPropsAsOwnerState( - element: React.ReactElement, + element: React.ReactElement<{ + slotProps: Record) => DataProps>; + className: string; + }>, getOptions: () => ConformanceOptions, ) { const { render, slots } = getOptions(); @@ -637,7 +649,11 @@ function testSlotPropsCallbackWithPropsAsOwnerState( * Components from @inheritComponent */ function testComponentsProp( - element: React.ReactElement, + element: React.ReactElement< + { + components?: Record; + } & DataProps + >, getOptions: () => ConformanceOptions, ) { describe('prop components:', () => { @@ -663,7 +679,7 @@ function testComponentsProp( * Components from @inheritComponent */ function testThemeDefaultProps( - element: React.ReactElement, + element: React.ReactElement, getOptions: () => ConformanceOptions, ) { describe('theme default components:', () => { @@ -747,7 +763,7 @@ function testThemeDefaultProps( * Components from @inheritComponent */ function testThemeStyleOverrides( - element: React.ReactElement, + element: React.ReactElement, getOptions: () => ConformanceOptions, ) { describe('theme style overrides:', () => { @@ -999,7 +1015,10 @@ function testThemeStyleOverrides( * MUI theme has a components section that allows specifying custom variants. * Components from @inheritComponent */ -function testThemeVariants(element: React.ReactElement, getOptions: () => ConformanceOptions) { +function testThemeVariants( + element: React.ReactElement, + getOptions: () => ConformanceOptions, +) { describe('theme variants:', () => { it("respect theme's variants", async function test(t = {}) { if (/jsdom/.test(window.navigator.userAgent)) { @@ -1109,7 +1128,7 @@ function testThemeVariants(element: React.ReactElement, getOptions: () => C * The components that iterate over the palette via `variants` should be able to render with or without applying the custom palette styles. */ function testThemeCustomPalette( - element: React.ReactElement, + element: React.ReactElement, getOptions: () => ConformanceOptions, ) { describe('theme extended palette:', () => {