Sha256: a3c341fa095cadbf6da7f3ebb32aa92d350182ca1f94ea5a764c2975d8823ea6

Contents?: true

Size: 1.15 KB

Versions: 31

Compression:

Stored size: 1.15 KB

Contents

import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import Immutable from 'seamless-immutable';
import {
  successResponse,
  getSuccessActions,
  getFailureActions,
} from './settings.fixtures';

import { loadSetting } from '../SettingsActions';

const mockStore = configureMockStore([thunk]);
const store = mockStore({ subscriptions: Immutable({}) });
const mockApi = new MockAdapter(axios);

afterEach(() => {
  store.clearActions();
  mockApi.reset();
});

describe('load setting actions  ', () => {
  const url = '/api/v2/settings/test_setting';

  describe('creates GET_SETTING_REQUEST', () => {
    it('and then fails with 422', () => {
      mockApi.onGet(url).reply(422);

      return store.dispatch(loadSetting('test_setting'))
        .then(() => expect(store.getActions()).toEqual(getFailureActions));
    });

    it('and ends with success', () => {
      mockApi.onGet(url).reply(200, successResponse);

      return store.dispatch(loadSetting('test_setting'))
        .then(() => expect(store.getActions()).toEqual(getSuccessActions));
    });
  });
});

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
katello-3.12.3 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.12.2 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.12.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.11.2 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.2 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.12.0 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.12.0.rc2 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.1.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.12.0.rc1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.11.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.11.0 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.11.0.rc2 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.11.0.rc1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.0 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.0.rc1.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.9.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.10.0.rc1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.9.0 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js
katello-3.8.1 webpack/move_to_foreman/Settings/__tests__/SettingsActions.test.js