Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Joy UI] Add
ListSubheader
component (#34191)
- Loading branch information
1 parent
7bff521
commit 04027ec
Showing
19 changed files
with
458 additions
and
74 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
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
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
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
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
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
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import * as React from 'react'; | ||
|
||
const NestedListContext = React.createContext(false); | ||
const NestedListContext = React.createContext<boolean | string>(false); | ||
|
||
export default NestedListContext; |
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
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
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
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
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,55 @@ | ||
import * as React from 'react'; | ||
import { expect } from 'chai'; | ||
import { spy } from 'sinon'; | ||
import { describeConformance, createRenderer } from 'test/utils'; | ||
import { ThemeProvider } from '@mui/joy/styles'; | ||
import ListSubheader, { listSubheaderClasses as classes } from '@mui/joy/ListSubheader'; | ||
import ListSubheaderDispatch from './ListSubheaderContext'; | ||
|
||
describe('Joy <ListSubheader />', () => { | ||
const { render } = createRenderer(); | ||
|
||
describeConformance(<ListSubheader />, () => ({ | ||
classes, | ||
inheritComponent: 'div', | ||
render, | ||
ThemeProvider, | ||
muiName: 'JoyListSubheader', | ||
refInstanceof: window.HTMLDivElement, | ||
testVariantProps: { variant: 'solid' }, | ||
testCustomVariant: true, | ||
skip: ['componentsProp', 'classesRoot'], | ||
})); | ||
|
||
it('should have root className', () => { | ||
const { container } = render(<ListSubheader />); | ||
expect(container.firstChild).to.have.class(classes.root); | ||
}); | ||
|
||
it('should accept className prop', () => { | ||
const { container } = render(<ListSubheader className="foo-bar" />); | ||
expect(container.firstChild).to.have.class('foo-bar'); | ||
}); | ||
|
||
it('should have variant class', () => { | ||
const { container } = render(<ListSubheader variant="soft" />); | ||
expect(container.firstChild).to.have.class(classes.variantSoft); | ||
}); | ||
|
||
it('should have color class', () => { | ||
const { container } = render(<ListSubheader color="success" />); | ||
expect(container.firstChild).to.have.class(classes.colorSuccess); | ||
}); | ||
|
||
it('should call dispatch context with the generated id', () => { | ||
const dispatch = spy(); | ||
const { container } = render( | ||
<ListSubheaderDispatch.Provider value={dispatch}> | ||
<ListSubheader /> | ||
</ListSubheaderDispatch.Provider>, | ||
); | ||
|
||
// @ts-ignore | ||
expect(dispatch.firstCall.calledWith(container.firstChild?.id)).to.equal(true); | ||
}); | ||
}); |
Oops, something went wrong.