Skip to content
Snippets Groups Projects
Select Git revision
  • a9b9b6d1c6878a1fab968cb30e6d31ddc0aa94fc
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

CollectionDialog.test.js

Blame
  • user avatar
    Chris Beer authored
    54b4fa20
    History
    CollectionDialog.test.js 1.64 KiB
    import { shallow } from 'enzyme';
    import Dialog from '@material-ui/core/Dialog';
    import DialogActions from '@material-ui/core/DialogActions';
    import Button from '@material-ui/core/Button';
    import MenuItem from '@material-ui/core/MenuItem';
    import Skeleton from '@material-ui/lab/Skeleton';
    import { Utils } from 'manifesto.js';
    import { CollectionDialog } from '../../../src/components/CollectionDialog';
    import collection from '../../fixtures/version-2/collection.json';
    
    /** */
    function createWrapper(props) {
      const manifest = Utils.parseManifest(props.manifest ? props.manifest : collection);
      CollectionDialog.prototype.dialogContainer = () => true;
      return shallow(
        <CollectionDialog
          addWindow={() => {}}
          classes={{}}
          ready
          manifest={manifest}
          t={(key) => key}
          {...props}
        />,
      );
    }
    
    describe('CollectionDialog', () => {
      it('renders a dialog with collection menu items', () => {
        const wrapper = createWrapper({});
        expect(wrapper.find(Dialog).length).toEqual(1);
        expect(wrapper.find(MenuItem).length).toEqual(55);
        expect(wrapper.find(MenuItem).first().text()).toEqual('Test 1 Manifest: Minimum Required Fields');
      });
      it('when not ready returns placeholder skeleton', () => {
        const wrapper = createWrapper({ ready: false });
        expect(wrapper.find(Skeleton).length).toEqual(3);
      });
      it('clicking the hide button fires hideCollectionDialog', () => {
        const hideCollectionDialog = jest.fn();
        const wrapper = createWrapper({ hideCollectionDialog });
        expect(wrapper.find(DialogActions).find(Button).first().simulate('click'));
        expect(hideCollectionDialog).toHaveBeenCalled();
      });
    });