Skip to content

Commit

Permalink
test: add case
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 committed Mar 29, 2023
1 parent 856394a commit 1143d31
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -807,5 +807,42 @@ describe('collapse', () => {
);
expect(container.querySelector('.custom-child')?.innerHTML).toBe('custom-child');
});

it('should work with accordion', () => {
const { container } = render(
<Collapse
onChange={onChange}
accordion
items={[
{
key: '1',
label: 'title 1',
children: 'first',
},
{
key: '2',
label: 'title 2',
children: 'second',
},
{
key: '3',
label: 'title 3',
children: 'third',
},
]}
/>,
);

let header = container.querySelectorAll('.rc-collapse-header')?.[1];
fireEvent.click(header);
jest.runAllTimers();
expect(container.querySelectorAll('.rc-collapse-content-active')).toHaveLength(1);
expect(container.querySelectorAll('.rc-collapse-item-active')).toHaveLength(1);
header = container.querySelectorAll('.rc-collapse-header')?.[1];
fireEvent.click(header);
jest.runAllTimers();
expect(container.querySelectorAll('.rc-collapse-content-active')).toHaveLength(0);
expect(container.querySelectorAll('.rc-collapse-item-active')).toHaveLength(0);
});
});
});

0 comments on commit 1143d31

Please sign in to comment.