Skip to content

Commit

Permalink
test: add nested accordion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tekno0ryder committed Jul 10, 2024
1 parent 9d38ef3 commit ebcdde8
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,41 @@ describe('Accordion', () => {
expect(ul).toBeInTheDocument();
});
});

describe('Nested Accordion', () => {
it('should not expand inner Accordion item when expanding outer Accordion item', () => {
render(
<Accordion>
<AccordionItem open>
<Accordion>
<AccordionItem>Panel</AccordionItem>
</Accordion>
</AccordionItem>
</Accordion>
);

const panel = screen.getByText('Panel');
expect(panel).not.toBeVisible();
});

it('should not close outer Accordion item when closing inner Accordion item', async () => {
render(
<Accordion>
<AccordionItem open>
outer panel
<Accordion>
<AccordionItem title="inner title" open>
inner panel
</AccordionItem>
</Accordion>
</AccordionItem>
</Accordion>
);

// close inner
await userEvent.click(screen.getByText('inner title'));

expect(screen.getByText('outer panel')).toBeVisible();
});
});
});

0 comments on commit ebcdde8

Please sign in to comment.