Sha256: fa2cf68c3c87045073f50ec22b2c4ecc284d2b75c93d8d21e120f4d09c534fd3

Contents?: true

Size: 1.16 KB

Versions: 121

Compression:

Stored size: 1.16 KB

Contents

import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
import api from '../../../../services/api';
import { apiError } from '../../../../utils/helpers';
import { loadModuleStreamDetails } from '../ModuleStreamDetailsActions';
import { details } from './moduleStreamDetails.fixtures';

jest.mock('../../../../services/api');
jest.mock('../../../../utils/helpers');

const fixtures = {
  'should load module stream details on success': () => async (dispatch) => {
    await loadModuleStreamDetails('1')(dispatch);

    expect(api.get.mock.calls).toMatchSnapshot('API get call');
    expect(apiError).not.toHaveBeenCalled();
  },
  'should load fail on bad api call': () => (dispatch) => {
    api.get.mockImplementation(async () => {
      throw new Error('some-error');
    });

    return loadModuleStreamDetails('1')(dispatch);
  },
};

describe('Module stream details actions', () => {
  beforeEach(() => {
    api.get.mockImplementation(async () => ({
      data: {
        results: details,
      },
    }));
  });
  afterEach(() => {
    jest.resetAllMocks();
    jest.restoreAllMocks();
    jest.resetModules();
  });

  testActionSnapshotWithFixtures(fixtures);
});

Version data entries

121 entries across 121 versions & 1 rubygems

Version Path
katello-3.17.0.rc1 webpack/scenes/ModuleStreams/Details/__tests__/ModuleStreamDetailsActions.test.js