Sha256: 7633bc21b75a6bd2d8ea8087ca8779b24f8eed51f1fa7d4b22b36d7d3fe0be60
Contents?: true
Size: 1.87 KB
Versions: 81
Compression:
Stored size: 1.87 KB
Contents
import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; import thunk from 'redux-thunk'; import Immutable from 'seamless-immutable'; import configureMockStore from 'redux-mock-store'; import { mockRequest, mockReset } from '../../../mockRequest'; import { requestSuccessResponse, getSuccessActions, getFailureActions, saveSuccessActions, saveFailureActions, } from './organizations.fixtures'; import { loadOrganization, saveOrganization } from '../OrganizationActions'; const mockStore = configureMockStore([thunk]); const store = mockStore({ organization: Immutable({}) }); beforeEach(() => { store.clearActions(); mockReset(); }); describe('organization actions', () => { it('creates GET_ORGANIZATION_REQUEST and then fails with 422', async () => { mockRequest({ url: '/katello/api/v2/organizations/1', status: 422, }); await store.dispatch(loadOrganization()); expect(store.getActions()).toEqual(getFailureActions); }); it('creates GET_ORGANIZATION_REQUEST and ends with success', async () => { mockRequest({ url: '/katello/api/v2/organizations/1', response: requestSuccessResponse, }); await store.dispatch(loadOrganization()); expect(store.getActions()).toEqual(getSuccessActions); }); it('creates SAVE_ORGANIZATION_REQUEST and then fails with 422', async () => { const mock = new MockAdapter(axios); mock.onPut('/katello/api/v2/organizations/1').reply(422); await store.dispatch(saveOrganization()); expect(store.getActions()).toEqual(saveFailureActions); }); it('creates SAVE_ORGANIZATION_REQUEST and ends with success', async () => { const mock = new MockAdapter(axios); mock.onPut('/katello/api/v2/organizations/1').reply(200, requestSuccessResponse); await store.dispatch(saveOrganization()); expect(store.getActions()).toEqual(saveSuccessActions); }); });
Version data entries
81 entries across 81 versions & 1 rubygems