Skip to content
Snippets Groups Projects
Select Git revision
  • 5844ca84d03265d86d5da30566333d90439efd1b
  • 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

WindowTopMenu.test.js

Blame
  • user avatar
    Dickson Law authored and Chris Beer committed
    Replace the lines responsible for these errors:
    
    ```
    Warning: Failed prop type: The prop `onEntering` of `ForwardRef(Menu)` is deprecated. Use the `TransitionProps` prop instead.
    ```
    
    ```
    Warning: Failed prop type: The prop `onExit` of `ForwardRef(Menu)` is deprecated. Use the `TransitionProps` prop instead.
    ```
    5844ca84
    History
    WindowTopMenu.test.js 2.47 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import Menu from '@material-ui/core/Menu';
    import WindowThumbnailSettings from '../../../src/containers/WindowThumbnailSettings';
    import WindowViewSettings from '../../../src/containers/WindowViewSettings';
    import { WindowTopMenu } from '../../../src/components/WindowTopMenu';
    
    /** create wrapper */
    function createWrapper(props) {
      return shallow(
        <WindowTopMenu
          containerId="mirador"
          windowId="xyz"
          handleClose={() => {}}
          anchorEl={null}
          toggleDraggingEnabled={() => {}}
          {...props}
        />,
      );
    }
    
    describe('WindowTopMenu', () => {
      it('renders all needed elements', () => {
        const wrapper = createWrapper();
    
        expect(wrapper.find(Menu).length).toBe(1);
        expect(wrapper.find(WindowThumbnailSettings).length).toBe(1);
        expect(wrapper.find(WindowViewSettings).length).toBe(1);
        expect(wrapper.find('PluginHookWithHeader').length).toBe(1);
      });
    
      it('passes windowId to <WindowThumbnailSettings/>', () => {
        const wrapper = createWrapper();
        expect(wrapper.find(WindowThumbnailSettings)
          .first().props().windowId).toBe('xyz');
      });
    
      it('passses correct props to <Menu/> when no achor element given', () => {
        const handleClose = jest.fn();
        const toggleDraggingEnabled = jest.fn();
        const wrapper = createWrapper({ handleClose, toggleDraggingEnabled });
        expect(wrapper.find(Menu).first().props().anchorEl).toBe(null);
        expect(wrapper.find(Menu).first().props().open).toBe(false);
        expect(wrapper.find(Menu).first().props().onClose).toBe(handleClose);
        expect(wrapper.find(Menu).first().props().TransitionProps.onEntering)
          .toBe(toggleDraggingEnabled);
        expect(wrapper.find(Menu).first().props().TransitionProps.onExit)
          .toBe(toggleDraggingEnabled);
      });
    
      it('passses correct props to <Menu/> when achor element given', () => {
        const handleClose = jest.fn();
        const toggleDraggingEnabled = jest.fn();
        const anchorEl = {};
        const wrapper = createWrapper({ anchorEl, handleClose, toggleDraggingEnabled });
        expect(wrapper.find(Menu).first().props().anchorEl).toBe(anchorEl);
        expect(wrapper.find(Menu).first().props().open).toBe(true);
        expect(wrapper.find(Menu).first().props().onClose).toBe(handleClose);
        expect(wrapper.find(Menu).first().props().TransitionProps.onEntering)
          .toBe(toggleDraggingEnabled);
        expect(wrapper.find(Menu).first().props().TransitionProps.onExit)
          .toBe(toggleDraggingEnabled);
      });
    });