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

AnnotationCreation.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);
        });
      });
    });