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

auth.test.js

Blame
  • user avatar
    Chris Beer authored
    359063d4
    History
    auth.test.js 1.67 KiB
    import { authReducer } from '../../../src/state/reducers/auth';
    import ActionTypes from '../../../src/state/actions/action-types';
    
    describe('auth response reducer', () => {
      it('should handle ADD_AUTHENTICATION_REQUEST', () => {
        expect(authReducer({}, {
          id: 'abc123',
          profile: 'iiif/login',
          type: ActionTypes.ADD_AUTHENTICATION_REQUEST,
          windowId: 'main',
        })).toEqual({
          abc123: {
            id: 'abc123',
            isFetching: true,
            profile: 'iiif/login',
            windowId: 'main',
          },
        });
      });
      it('should handle RESOLVE_AUTHENTICATION_REQUEST', () => {
        expect(authReducer(
          {
            abc123: {
              id: 'abc123',
              isFetching: true,
            },
          },
          {
            id: 'abc123',
            ok: true,
            type: ActionTypes.RESOLVE_AUTHENTICATION_REQUEST,
          },
        )).toMatchObject({
          abc123: {
            id: 'abc123',
            isFetching: false,
            ok: true,
          },
        });
      });
      describe('should handle RECEIVE_ACCESS_TOKEN', () => {
        it('does nothing if id is not present', () => {
          expect(authReducer({ foo: {} }, {
            authId: 'foo',
            type: ActionTypes.RECEIVE_ACCESS_TOKEN,
          })).toMatchObject({ foo: { ok: true } });
        });
      });
      describe('should handle RESET_AUTHENTICATION_STATE', () => {
        it('does nothing if id is not present', () => {
          expect(authReducer({}, {
            id: 'foo',
            type: ActionTypes.RESET_AUTHENTICATION_STATE,
          })).toEqual({});
        });
        it('removes id', () => {
          expect(authReducer({
            foo: 'otherStuff',
          }, {
            id: 'foo',
            type: ActionTypes.RESET_AUTHENTICATION_STATE,
          })).toEqual({});
        });
      });
    });