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

jest.config.js

Blame
  • infoResponse.test.js 2.28 KiB
    import { infoResponsesReducer } from '../../../src/state/reducers/infoResponses';
    import ActionTypes from '../../../src/state/actions/action-types';
    
    describe('info response reducer', () => {
      it('should handle REQUEST_INFO_RESPONSE', () => {
        expect(infoResponsesReducer({}, {
          infoId: 'abc123',
          type: ActionTypes.REQUEST_INFO_RESPONSE,
        })).toEqual({
          abc123: {
            id: 'abc123',
            isFetching: true,
          },
        });
      });
      it('should handle RECEIVE_INFO_RESPONSE', () => {
        expect(infoResponsesReducer(
          {
            abc123: {
              id: 'abc123',
              isFetching: true,
            },
          },
          {
            infoId: 'abc123',
            infoJson: {
              '@type': 'sc:Manifest',
              content: 'lots of canvases and metadata and such',
              id: 'abc123',
            },
            tokenServiceId: 'efg456',
            type: ActionTypes.RECEIVE_INFO_RESPONSE,
          },
        )).toMatchObject({
          abc123: {
            id: 'abc123',
            isFetching: false,
            json: {},
            tokenServiceId: 'efg456',
          },
        });
      });
      it('should handle RECEIVE_INFO_RESPONSE_FAILURE', () => {
        expect(infoResponsesReducer(
          {
            abc123: {
              id: 'abc123',
              isFetching: true,
            },
          },
          {
            error: "This institution didn't enable CORS.",
            infoId: 'abc123',
            tokenServiceId: 'efg456',
            type: ActionTypes.RECEIVE_INFO_RESPONSE_FAILURE,
          },
        )).toEqual({
          abc123: {
            error: "This institution didn't enable CORS.",
            id: 'abc123',
            isFetching: false,
            tokenServiceId: 'efg456',
          },
        });
      });
      it('should handle REMOVE_INFO_RESPONSE', () => {
        expect(infoResponsesReducer(
          {
            abc123: {
              id: 'abc123',
              stuff: 'foo',
            },
            def456: {
              id: 'def456',
              stuff: 'foo',
            },
          },
          {
            infoId: 'abc123',
            type: ActionTypes.REMOVE_INFO_RESPONSE,
          },
        )).toEqual({
          def456: {
            id: 'def456',
            stuff: 'foo',
          },
        });
      });
      it('should handle IMPORT_MIRADOR_STATE setting to clean state', () => {
        expect(infoResponsesReducer({}, {
          state: { infoResponses: { new: 'stuff' } },
          type: ActionTypes.IMPORT_MIRADOR_STATE,
        })).toEqual({});
      });
    });