-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathCollectionInfo.test.jsx
More file actions
41 lines (34 loc) · 1.34 KB
/
CollectionInfo.test.jsx
File metadata and controls
41 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { render, screen } from '@tests/utils/test-utils';
import userEvent from '@testing-library/user-event';
import { CollectionInfo } from '../../../src/components/CollectionInfo';
/** */
function createWrapper(props) {
return render(
<CollectionInfo
collectionPath={[1, 2]}
showCollectionDialog={() => {}}
{...props}
/>,
);
}
describe('CollectionInfo', () => {
it('renders a collapsible section', async () => {
const user = userEvent.setup();
createWrapper();
expect(screen.getByRole('heading', { name: 'Collection' })).toBeVisible();
expect(screen.getByRole('button', { name: 'Show collection' })).toBeVisible();
await user.click(screen.getByRole('button', { name: 'Collapse "Collection" section' }));
expect(screen.queryByRole('button', { name: 'Show collection' })).not.toBeInTheDocument();
});
it('without a collectionPath, renders nothing', () => {
const wrapper = createWrapper({ collectionPath: [] });
expect(wrapper.container).toBeEmptyDOMElement();
});
it('clicking the button fires showCollectionDialog', async () => {
const user = userEvent.setup();
const showCollectionDialog = vi.fn();
createWrapper({ showCollectionDialog });
await user.click(screen.getByRole('button', { name: 'Show collection' }));
expect(showCollectionDialog).toHaveBeenCalled();
});
});