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

AttributionPanel.test.js

Blame
  • Loïs Poujade's avatar
    Loïs Poujade authored
    ran `npx @mui/codemod v5.0.0/link-underline-hover`
    6c8aee89
    History
    AttributionPanel.test.js 2.31 KiB
    import React from 'react';
    import { shallow } from 'enzyme';
    import Typography from '@mui/material/Typography';
    import Link from '@mui/material/Link';
    import { Img } from 'react-image';
    import { AttributionPanel } from '../../../src/components/AttributionPanel';
    import { LabelValueMetadata } from '../../../src/components/LabelValueMetadata';
    
    /**
     * Helper function to create a shallow wrapper around AttributionPanel
     */
    function createWrapper(props) {
      return shallow(
        <AttributionPanel
          id="xyz"
          t={str => str}
          windowId="window"
          {...props}
        />,
      );
    }
    
    describe('AttributionPanel', () => {
      it('renders the required statement', () => {
        const requiredStatement = [
          { label: 'x', value: 'y' },
        ];
        const wrapper = createWrapper({ requiredStatement });
        expect(wrapper.find(LabelValueMetadata).length).toBe(1);
      });
    
      it('renders the rights statement', () => {
        const wrapper = createWrapper({ rights: ['http://example.com', 'http://stanford.edu'] });
        expect(
          wrapper.find(Typography).at(0).matchesElement(
            <Typography>rights</Typography>,
          ),
        ).toBe(true);
        expect(
          wrapper.find(Typography).at(1).matchesElement(
            <Typography>
              <Link href="http://example.com" underline="hover">http://example.com</Link>
            </Typography>,
          ),
        ).toBe(true);
        expect(
          wrapper.find(Typography).at(2).matchesElement(
            <Typography>
              <Link href="http://stanford.edu" underline="hover">http://stanford.edu</Link>
            </Typography>,
          ),
        ).toBe(true);
      });
    
      it('renders the rights statement', () => {
        const wrapper = createWrapper({ rights: [] });
        expect(
          wrapper.find(Typography).length,
        ).toBe(0);
      });
    
      it('renders the manifest logo', () => {
        const manifestLogo = 'http://example.com';
        const wrapper = createWrapper({ manifestLogo });
        expect(wrapper.find(Img).length).toBe(1);
        expect(wrapper.find(Img).props().src).toEqual([manifestLogo]);
      });
    
      describe('when metadata is not present', () => {
        it('does not render empty elements elements', () => {
          const wrapper = createWrapper({});
          expect(wrapper.find(LabelValueMetadata).length).toBe(0);
          expect(wrapper.find(Typography).length).toBe(0);
          expect(wrapper.find(Img).length).toBe(0);
        });
      });
    });