From 9cf0d60563cfb93877b611b95a1cd1799ee9d762 Mon Sep 17 00:00:00 2001 From: Jack Reed <phillipjreed@gmail.com> Date: Fri, 24 Jul 2020 12:37:01 -0600 Subject: [PATCH] Backfill CollectionInfo test --- .../src/components/CollectionInfo.test.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 __tests__/src/components/CollectionInfo.test.js diff --git a/__tests__/src/components/CollectionInfo.test.js b/__tests__/src/components/CollectionInfo.test.js new file mode 100644 index 000000000..b990a49f7 --- /dev/null +++ b/__tests__/src/components/CollectionInfo.test.js @@ -0,0 +1,34 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import Button from '@material-ui/core/Button'; +import { CollectionInfo } from '../../../src/components/CollectionInfo'; +import CollapsibleSection from '../../../src/containers/CollapsibleSection'; + +/** */ +function createWrapper(props) { + return shallow( + <CollectionInfo + id="test" + collectionPath={[1, 2]} + showCollectionDialog={() => {}} + {...props} + />, + ); +} + +describe('CollectionInfo', () => { + it('renders a collapsible section', () => { + const wrapper = createWrapper(); + expect(wrapper.find(CollapsibleSection).length).toEqual(1); + }); + it('without a collectionPath, renders nothing', () => { + const wrapper = createWrapper({ collectionPath: [] }); + expect(wrapper.find(CollapsibleSection).length).toEqual(0); + }); + it('clicking the button fires showCollectionDialog', () => { + const showCollectionDialog = jest.fn(); + const wrapper = createWrapper({ showCollectionDialog }); + expect(wrapper.find(Button).first().simulate('click')); + expect(showCollectionDialog).toHaveBeenCalled(); + }); +}); -- GitLab