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

SearchHit.test.js

Blame
  • user avatar
    Jessie Keck authored and Chris Beer committed
    d551c993
    History
    SearchHit.test.js 1.75 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import { SearchHit } from '../../../src/components/SearchHit';
    
    
    /**
     * Helper function to create a shallow wrapper around SearchResults
     */
    function createWrapper(props) {
      return shallow(
        <SearchHit
          hit={{
            after: ', and start the chainsaw',
            annotations: ['foo'],
            before: 'Light up the',
            match: 'moose',
          }}
          windowId="window"
          selected
          index={0}
          {...props}
        />,
      );
    }
    
    describe('SearchHit', () => {
      it('renders a ListItem for each hit', () => {
        const selectContentSearchAnnotation = jest.fn();
        const wrapper = createWrapper({ selectContentSearchAnnotation });
        expect(wrapper.find('WithStyles(ForwardRef(ListItem))').length).toEqual(1);
        expect(wrapper.find('WithStyles(ForwardRef(ListItem))').prop('selected')).toEqual(true);
        expect(wrapper.find('WithStyles(ForwardRef(ListItemText))').render().text()).toEqual('1Light up the moose , and start the chai more');
        expect(wrapper.find('strong').length).toEqual(1);
    
        wrapper.find('WithStyles(ForwardRef(ListItem))').simulate('click');
        expect(selectContentSearchAnnotation).toHaveBeenCalledWith('window', ['foo']);
      });
    
      describe('Annotation Labels', () => {
        it('renders the annotationLabel if present', () => {
          const wrapper = createWrapper({ annotationLabel: 'The Anno Label' });
    
          expect(wrapper.find('WithStyles(ForwardRef(Typography))[variant="subtitle2"][children="The Anno Label"]').length).toEqual(1);
        });
    
        it('does not render the typography if no annotation label is present', () => {
          const wrapper = createWrapper();
    
          expect(wrapper.find('WithStyles(ForwardRef(Typography))[variant="subtitle2"]').length).toEqual(0);
        });
      });
    });