Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/List/ListAccordionGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ListAccordionGroup = ({
return (
<ListAccordionGroupContext.Provider
value={{
expandedId: expandedIdProp || expandedId, // component can be controlled or uncontrolled
expandedId: expandedIdProp ?? expandedId, // component can be controlled or uncontrolled
onAccordionPress: onAccordionPress || onAccordionPressDefault,
}}
>
Expand Down
31 changes: 30 additions & 1 deletion src/components/__tests__/ListAccordion.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { StyleSheet, View } from 'react-native';

import { describe, expect, it } from '@jest/globals';

import { render, screen } from '../../test-utils';
import { render, screen, within } from '../../test-utils';
import { red500 } from '../../theme/colors';
import { LightTheme } from '../../theme/schemes';
import ListAccordion from '../List/ListAccordion';
Expand Down Expand Up @@ -150,6 +150,35 @@ describe('ListAccordion', () => {
});
});

describe('ListAccordionGroup', () => {
it('expands the accordion with id={0} and keeps id={1} collapsed when expandedId={0}', async () => {
await render(
<ListAccordionGroup expandedId={0}>
<ListAccordion title="Accordion 0" id={0}>
<ListItem title="Item 0" />
</ListAccordion>
<ListAccordion title="Accordion 1" id={1}>
<ListItem title="Item 1" />
</ListAccordion>
</ListAccordionGroup>
);

expect(
within(screen.getByRole('button', { expanded: true })).getByText(
'Accordion 0'
)
).toBeOnTheScreen();
expect(screen.getByText('Item 0')).toBeOnTheScreen();

expect(
within(screen.getByRole('button', { expanded: false })).getByText(
'Accordion 1'
)
).toBeOnTheScreen();
expect(screen.queryByText('Item 1')).not.toBeOnTheScreen();
});
});

describe('getAccordionColors - description color', () => {
it('should return theme color, for theme version 3', () => {
expect(
Expand Down
Loading