-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(APP-3954): Update Tab component to hide the TabList when used wi…
…th only one tab (#407)
- Loading branch information
Showing
5 changed files
with
52 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
// TabsRoot.test.tsx | ||
import { render, screen } from '@testing-library/react'; | ||
import { Tabs, type ITabsListProps } from '../../tabs'; | ||
import { type ITabsListProps, Tabs } from '../../tabs'; | ||
|
||
describe('<Tabs.Root /> component', () => { | ||
describe('<Tabs.List /> component', () => { | ||
const createTestComponent = (props?: Partial<ITabsListProps>) => { | ||
const completeProps: ITabsListProps = { | ||
...props, | ||
}; | ||
|
||
return ( | ||
<Tabs.Root> | ||
<Tabs.List {...completeProps}> | ||
<Tabs.Trigger label="Tab 1" value="1" /> | ||
<Tabs.Trigger label="Tab 2" value="2" /> | ||
</Tabs.List> | ||
<Tabs.List {...completeProps} /> | ||
</Tabs.Root> | ||
); | ||
}; | ||
|
||
it('should render multiple tab triggers without crashing', () => { | ||
render(createTestComponent()); | ||
it('renders multiple tab triggers', () => { | ||
const children = [ | ||
<Tabs.Trigger key="1" label="Tab 1" value="1" />, | ||
<Tabs.Trigger key="2" label="Tab 2" value="2" />, | ||
]; | ||
render(createTestComponent({ children })); | ||
|
||
expect(screen.getByText('Tab 1')).toBeInTheDocument(); | ||
expect(screen.getByText('Tab 2')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders null when only a single tab trigger is present', () => { | ||
const children = <Tabs.Trigger label="Tab 1" value="1" />; | ||
render(createTestComponent({ children })); | ||
|
||
expect(screen.queryByText('Tab 1')).not.toBeInTheDocument(); | ||
}); | ||
}); |
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