Skip to content
Snippets Groups Projects
Select Git revision
  • 18b35d27bd80705482bdefeb034e66c509e1ddd2
  • mui5-tetras-main-stable default protected
  • mui5-tetras-main-old-stable
  • preprod protected
  • 75-dernieres-ameliorations-avant-workshop-du-7-02
  • wip-fix-xywh
  • wip-positionement-annot
  • wip-surface-transformer
  • uploads-file
  • 69-la-video-demare-quand-on-fait-glisser-le-slider-et-le-clic-creer-un-decalage-entre-le-player
  • 61-recettage-des-outils-d-annotation
  • gestion_multiple_ouverture_pannel_annotation
  • autorisation_un_pannel_annotation
  • autorisation_un_pannel_edition_annotation
  • récupération_temps_video
  • save-shapes-and-position
  • fix-error-create-annotation-pannel
  • time-saving-on-annotation
  • tetras-main protected
  • fix-poc-mirador
  • tetras-antho-test
21 results

miradorAnnotationPlugin.test.js

Blame
  • user avatar
    Lutz Helm authored
    18b35d27
    History
    miradorAnnotationPlugin.test.js 1.60 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import { MiradorMenuButton } from 'mirador/dist/es/src/components/MiradorMenuButton';
    import miradorAnnotationPlugin from '../src/plugins/miradorAnnotationPlugin';
    
    /** */
    function createWrapper(props) {
      return shallow(
        <miradorAnnotationPlugin.component
          config={{}}
          TargetComponent="<div>hello</div>"
          targetProps={{}}
          addCompanionWindow={jest.fn()}
          receiveAnnotation={jest.fn()}
          switchToSingleCanvasView={jest.fn()}
          windowViewType="single"
          {...props}
        />,
      );
    }
    
    describe('MiradorAnnotation', () => {
      let wrapper;
      it('renders a create new button', () => {
        wrapper = createWrapper();
        expect(wrapper.find(MiradorMenuButton).props()['aria-label']).toBe('Create new annotation');
      });
      it('opens a new companionWindow when clicked', () => {
        const mockAddCompanionWindow = jest.fn();
        const receiveAnnotationMock = jest.fn();
        wrapper = createWrapper({
          addCompanionWindow: mockAddCompanionWindow,
          receiveAnnotation: receiveAnnotationMock,
        });
        wrapper.find(MiradorMenuButton).simulate('click');
        expect(mockAddCompanionWindow).toHaveBeenCalledWith(
          'annotationCreation',
          {
            position: 'right',
          },
        );
      });
      it('opens single canvas view dialog if not in single view', () => {
        wrapper = createWrapper({
          windowViewType: 'book',
        });
        expect(wrapper.instance().state.singleCanvasDialogOpen).toBe(false);
        wrapper.find(MiradorMenuButton).simulate('click');
        expect(wrapper.instance().state.singleCanvasDialogOpen).toBe(true);
      });
    });