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

CaptionedCanvasThumbnail.js

Blame
  • LabelValueMetadata.test.js 1.99 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import { LabelValueMetadata } from '../../../src/components/LabelValueMetadata';
    import { SanitizedHtml } from '../../../src/components/SanitizedHtml';
    
    describe('LabelValueMetadata', () => {
      let wrapper;
      let labelValuePair;
    
      describe('when the labelValuePair has content', () => {
        beforeEach(() => {
          labelValuePair = [
            {
              label: 'Label 1',
              value: 'Value 1',
            },
            {
              label: 'Label 2',
              value: 'Value 2',
            },
          ];
          wrapper = shallow(
            <LabelValueMetadata labelValuePairs={labelValuePair} />,
          );
        });
    
        it('renders a dt/dd for each label/value pair', () => {
          expect(wrapper.find('dl').length).toEqual(1);
          expect(wrapper.find('dt').length).toEqual(2);
          expect(wrapper.find('dd').length).toEqual(2);
        });
    
        it('renders correct labels in dt', () => {
          expect(wrapper.find('dt WithStyles(Typography)').first().children().text()).toEqual('Label 1');
          expect(wrapper.find('dt WithStyles(Typography)').last().children().text()).toEqual('Label 2');
        });
    
        it('renders SanitizedHtml component in dt for each value', () => {
          expect(wrapper.find('dd').first().find(SanitizedHtml).length).toBe(1);
          expect(wrapper.find('dd').last().find(SanitizedHtml).length).toBe(1);
        });
    
        it('passes value string to SanitizedHtml', () => {
          expect(wrapper.find(SanitizedHtml).first().props().htmlString).toBe('Value 1');
          expect(wrapper.find(SanitizedHtml).last().props().htmlString).toBe('Value 2');
        });
      });
    
      describe('when the labelValuePair has no content', () => {
        beforeEach(() => {
          labelValuePair = [];
          wrapper = shallow(
            <LabelValueMetadata labelValuePairs={labelValuePair} />,
          );
        });
    
        it('renders an empty fragment instead of an empty dl', () => {
          expect(wrapper.find('dl').length).toEqual(0);
          expect(wrapper.matchesElement(<></>)).toBe(true);
        });
      });
    });