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

CanvasAnnotations.js

Blame
  • WindowSideBarAnnotationsPanel.test.js 2.72 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import AnnotationSettings from '../../../src/containers/AnnotationSettings';
    import { WindowSideBarAnnotationsPanel } from '../../../src/components/WindowSideBarAnnotationsPanel';
    
    /** */
    function createWrapper(props) {
      return shallow(
        <WindowSideBarAnnotationsPanel
          classes={{}}
          deselectAnnotation={() => {}}
          selectAnnotation={() => {}}
          id="xyz"
          windowId="abc"
          {...props}
        />,
      );
    }
    
    describe('WindowSideBarAnnotationsPanel', () => {
      let wrapper;
    
      it('has a header', () => {
        wrapper = createWrapper();
    
        expect(
          wrapper.props().title,
        ).toBe('annotations');
      });
    
      it('has the AnnotationSettings component', () => {
        expect(createWrapper().find(AnnotationSettings).length).toBe(1);
      });
    
      it('renders a list with a list item for each annotation', () => {
        wrapper = createWrapper({
          annotations: [
            {
              content: 'First Annotation',
              id: 'abc123',
            },
            {
              content: 'Last Annotation',
              id: 'xyz321',
            },
          ],
        });
    
        expect(wrapper.find('WithStyles(ListItem)').length).toBe(2);
        expect(wrapper.find('SanitizedHtml[htmlString="First Annotation"]').length).toBe(1);
        expect(wrapper.find('SanitizedHtml[htmlString="Last Annotation"]').length).toBe(1);
      });
    
      it('triggers the selectAnnotation prop with the correct arguments when clicking an unselected annotation', () => {
        const selectAnnotation = jest.fn();
    
        wrapper = createWrapper({
          annotations: [
            {
              content: 'First Annotation',
              id: 'abc123',
              targetId: 'example.com/iiif/12345',
            },
            {
              content: 'Last Annotation',
              id: 'xyz321',
              targetId: 'example.com/iiif/54321',
            },
          ],
          selectAnnotation,
        });
    
        wrapper.find('WithStyles(ListItem)').first().simulate('click');
        expect(selectAnnotation).toHaveBeenCalledWith('abc', 'example.com/iiif/12345', 'abc123');
      });
    
      it('triggers the deselectAnnotation prop with the correct arguments when clicking a selected annotation', () => {
        const deselectAnnotation = jest.fn();
    
        wrapper = createWrapper({
          annotations: [
            {
              content: 'First Annotation',
              id: 'abc123',
              targetId: 'example.com/iiif/12345',
            },
            {
              content: 'Last Annotation',
              id: 'xyz321',
              targetId: 'example.com/iiif/54321',
            },
          ],
          deselectAnnotation,
          selectedAnnotationIds: ['abc123'],
        });
    
        wrapper.find('WithStyles(ListItem)').first().simulate('click');
        expect(deselectAnnotation).toHaveBeenCalledWith('abc', 'example.com/iiif/12345', 'abc123');
      });
    });