components APIs
- Header
- Button
- Layout
- Footer
- Text
- Box
- Card
- Table
- Loading
- Select
- Loader
- Toolbar
- Icon
- CodeInput
- BottomSheet
- InfoBlock
- LanguageToggle
- ProgressCircles
- Ripple
- Toggle
- Tag
- Input
- Paginator
- Filter
- AsyncSelect
- CatalogBigButton
- ReadMore
- ConditionalWrapper
- LastCheckedDisplay
- PriceLabel
- PageTitle
- CartTable
- CartFinalPriceTable
- LoadingSpin
- InfoModal
- ProductCard
- RecommendCoupon
- PriceVales
- NomalLayout
- Web3ReactManager
- Popups
- CurrencyInput
- TransactionErrorContent
- TransactionConfirmationModal
- ConfirmationModalContent
- DoubleCurrencyLogo
- CustomModal
- CurrencySearchModal
- CurrencyLogo
- NumericalInput
- Logo
- QuestionHelper
- ListLogo
- DataTable
- WalletModal
- CustomTable
- MinimalPositionCard
- RemoveLiquidityModal
- CustomTooltip
- ColoredSlider
- ToggleSwitch
- FormattedPriceImpact
- SettingsModal
- ConfirmSwapModal
- AdvancedSwapDetails
- AddressInput
- LineChart
- StakeSyrupModal
- AccountDetails
- BetaWarningBanner
- AreaChart
- ChartType
- TokensTable
- PairTable
- TopMovers
- BarChart
- TransactionsTable
- StakeQuickModal
- UnstakeQuickModal
- SyrupCard
- CustomMenu
- SearchInput
- CustomSwitch
- FarmCard
- BuyFiatModal
- MoonpayModal
- RewardSlider
- Swap
- AddLiquidity
- PoolFinderModal
- PoolPositionCard
- SwapTokenDetails
- SuperHeader
- GlobalStyles
- PrimaryButton
- SectionTitle
- Section
- AccentSection
- ChainSelection
- CoinSelection
- AddressSelection
- SendAction
- Buttons
- Content
- Particles
- IconButton
- NotSupported
- InputSearch
- RouteGuard
- SearchBar
- FileInput
- GovBanner
- AuthForm
- DomainDetails
- Subnav
- ColumnFilter
- ImportExport
- selectFilter
- TaggedArrayInput
- FacetFilter
- ButtonSingleLine
- TextMultiline
- ButtonSelect
- BottomSheetBehavior
- InfoButton
- BulletPointX
- BulletPointCheck
- Title
- LoadingIcon
- SelectFilterControls
- CORInputForm
- SdnInputForm
- Navbar
- HomeRoute
- AuthRoute
- DocumentDetails
- DocumentStepper
- AddGame
- Auth
- Effectiveness
- Export
- PokemonType
- Moves
- Member
- MoveSelector
- Type
- Natures
- Move
- PokeInfo
- Share
- Badges
- Status
- UpdateSW
- About
- Builder
- Calculator
- Changelog
- Import
- Pokestats
- Report
- Rules
- Settings
- Tracker
- DarkThemeProvider
- NotificationHandler
- Background
- Indicator
- StyledButton
- StyledText
- Illustration
- OnboardingSlider
- FlexList
- AppLayout
- ScrollableList
- Visualization
- DataSearch
- Region
- App
- CompareApiLegend
- CompareApiBreadcrumbs
- CompareApiLink
- CompareApiCard
- ExploreApiBreadcrumbs
- ExploreApiLink
- ExploreApiSearch
- ExploreApiConst
- ApiLoader
- RefreshButton
- Listing
- PriceModal
- ConfirmationModal
- Transition
- AutoComplete
- useInput
- Avatar
- Badge
- Breadcrumbs
- ButtonDropdown
- ButtonGroup
- Capacity
- Checkbox
- Code
- Collapse
- CssBaseline
- GeistProvider
- Description
- Display
- Divider
- Dot
- Drawer
- useModal
- Fieldset
- Grid
- Image
- Keyboard
- Link
- Modal
- Note
- Page
- Pagination
- Popover
- Progress
- Radio
- Rating
- Slider
- Snippet
- Spacer
- Spinner
- Tabs
- Textarea
- Tooltip
- Tree
- useBodyScroll
- useClasses
- useClickAway
- useClipboard
- useCurrentState
- useKeyboard
- KeyMod
- KeyCode
- useMediaQuery
- useTabs
- useToasts
- User
- useTheme
- Themes
- GeistUIThemes
- useAllThemes
- CollapsableDialog
- Map
- IPForm
- IPMenu
- Container
- Parallax
- Nav
- SEO
- BlogNav
- ExtensionCard
- MenuComp
Other Related APIs
components#Collapse TypeScript Examples
The following examples show how to use
components#Collapse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: group.test.tsx From geist-ui with MIT License | 5 votes |
describe('Collapse Group', () => {
it('should render correctly', () => {
const wrapper = mount(
<Collapse.Group>
<Collapse title="title1">content1</Collapse>
<Collapse title="title2">content2</Collapse>
</Collapse.Group>,
)
expect(wrapper).toMatchSnapshot()
expect(() => wrapper.unmount()).not.toThrow()
})
it('should be no errors when children are missing', () => {
const wrapper = mount(<Collapse.Group></Collapse.Group>)
expect(wrapper).toMatchSnapshot()
expect(() => wrapper.unmount()).not.toThrow()
})
it('should work without accordion', () => {
const wrapper = render(
<Collapse.Group accordion={false}>
<Collapse title="title1">content1</Collapse>
<Collapse title="title2">content2</Collapse>
</Collapse.Group>,
)
expect(wrapper).toMatchSnapshot()
})
it('should be display all when without accordion', async () => {
const wrapper = mount(
<Collapse.Group accordion={false}>
<Collapse title="title1">content1</Collapse>
<Collapse title="title2">content2</Collapse>
</Collapse.Group>,
)
const views = wrapper.find('.view')
views.at(0).simulate('click')
views.at(1).simulate('click')
await updateWrapper(wrapper, 300)
expect(wrapper.find('.expanded').length).toBe(2)
views.at(0).simulate('click')
views.at(1).simulate('click')
await updateWrapper(wrapper, 300)
expect(wrapper.find('.expanded').length).toBe(0)
})
it('should be display one when in accordion mode', async () => {
const wrapper = mount(
<Collapse.Group>
<Collapse title="title1">content1</Collapse>
<Collapse title="title2">content2</Collapse>
</Collapse.Group>,
)
const views = wrapper.find('.view')
views.at(0).simulate('click')
views.at(1).simulate('click')
await updateWrapper(wrapper, 300)
expect(wrapper.find('.expanded').length).toBe(1)
views.at(1).simulate('click')
await updateWrapper(wrapper, 300)
expect(wrapper.find('.expanded').length).toBe(0)
})
})
Example #2
Source File: index.test.tsx From geist-ui with MIT License | 5 votes |
describe('Collapse', () => {
it('should render correctly', () => {
const wrapper = mount(<Collapse title="title">content</Collapse>)
expect(wrapper).toMatchSnapshot()
expect(() => wrapper.unmount()).not.toThrow()
})
it('should work with subtitle and shadow', () => {
const wrapper = render(
<div>
<Collapse title="title" subtitle="subtitle">
content
</Collapse>
<Collapse title="title" subtitle="subtitle" shadow>
content
</Collapse>
</div>,
)
expect(wrapper).toMatchSnapshot()
})
it('should work with initial visible', () => {
const wrapper = render(
<div>
<Collapse title="title" subtitle="subtitle">
content
</Collapse>
<Collapse title="title" initialVisible>
content
</Collapse>
</div>,
)
expect(wrapper).toMatchSnapshot()
})
it('should throw error when title missing', () => {
const Component = Collapse as any
let errorMessage = ''
const errorSpy = jest
.spyOn(console, 'error')
.mockImplementation(msg => (errorMessage = msg))
mount(<Component subtitle="subtitle">content</Component>)
expect(errorMessage.toLowerCase()).not.toEqual('')
errorSpy.mockRestore()
})
it('should expand when title clicked', async () => {
const wrapper = mount(<Collapse title="title">content</Collapse>)
wrapper.find('.view').at(0).simulate('click')
await updateWrapper(wrapper, 300)
expect(wrapper.find('.expanded').length).not.toBe(0)
})
})