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

WindowThumbnailSettings.test.js

Blame
  • user avatar
    Mathias Maaß authored and Mathias Maaß committed
    1d63e78f
    History
    WindowThumbnailSettings.test.js 1.88 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import FormControlLabel from '@material-ui/core/FormControlLabel';
    import RadioGroup from '@material-ui/core/RadioGroup';
    import Typography from '@material-ui/core/Typography';
    import WindowThumbnailSettings from '../../../src/components/WindowThumbnailSettings';
    
    /** create wrapper */
    function createWrapper(props) {
      return shallow(
        <WindowThumbnailSettings
          windowId="xyz"
          setWindowThumbnailPosition={() => {}}
          thumbnailNavigationPosition="off"
          {...props}
        />,
      );
    }
    
    describe('WindowThumbnailSettings', () => {
      it('renders all elements correctly', () => {
        const wrapper = createWrapper();
        expect(wrapper.find(Typography).length).toBe(1);
        expect(wrapper.find(RadioGroup).length).toBe(1);
        const labels = wrapper.find(FormControlLabel);
        expect(labels.length).toBe(3);
        expect(labels.at(0).props().value).toBe('off');
        expect(labels.at(1).props().value).toBe('bottom');
        expect(labels.at(2).props().value).toBe('right');
      });
    
      it('should set the correct label active', () => {
        let wrapper = createWrapper({ thumbnailNavigationPosition: 'bottom' });
        expect(wrapper.find(RadioGroup).props().value).toBe('bottom');
        wrapper = createWrapper({ thumbnailNavigationPosition: 'right' });
        expect(wrapper.find(RadioGroup).props().value).toBe('right');
      });
    
      it('updates state when the thumbnail config selection changes', () => {
        const setWindowThumbnailPosition = jest.fn();
        const wrapper = createWrapper({ setWindowThumbnailPosition });
        wrapper.find(RadioGroup).first().simulate('change', { target: { value: 'off' } });
        expect(setWindowThumbnailPosition).toHaveBeenCalledWith('xyz', 'off');
        wrapper.find(RadioGroup).first().simulate('change', { target: { value: 'right' } });
        expect(setWindowThumbnailPosition).toHaveBeenCalledWith('xyz', 'right');
      });
    });