-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Exclude
undefined
className from render fn props (#1041)
- Loading branch information
1 parent
e70f892
commit a89b832
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import { expect } from 'chai'; | ||
import { createRenderer } from '@mui/internal-test-utils'; | ||
import { useComponentRenderer, type ComponentRendererSettings } from './useComponentRenderer'; | ||
|
||
describe('useComponentRenderer', () => { | ||
const { render } = createRenderer(); | ||
|
||
it('render props does not overwrite className in a render function when unspecified', async () => { | ||
function TestComponent(props: { | ||
render: ComponentRendererSettings<any, Element>['render']; | ||
className?: ComponentRendererSettings<any, Element>['className']; | ||
}) { | ||
const { render: renderProp, className } = props; | ||
const { renderElement } = useComponentRenderer({ | ||
render: renderProp, | ||
state: {}, | ||
className, | ||
}); | ||
return renderElement(); | ||
} | ||
|
||
const { container } = await render( | ||
<TestComponent | ||
render={(props: any, state: any) => <span className="my-span" {...props} {...state} />} | ||
/>, | ||
); | ||
|
||
const element = container.firstElementChild; | ||
|
||
expect(element).to.have.attribute('class', 'my-span'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters