Sha256: 1580a9819946393007209ab27b0195233f3ae8d4f108c25e4b5b863465099c38
Contents?: true
Size: 1.27 KB
Versions: 45
Compression:
Stored size: 1.27 KB
Contents
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils'; import api, { orgId } from '../../../services/api'; import { apiError } from '../../../move_to_foreman/common/helpers'; import { loadOrganizationProducts } from '../OrganizationProductsActions'; const params = { search: 'some-search', }; jest.mock('../../../services/api'); jest.mock('../../../move_to_foreman/common/helpers'); const fixtures = { 'should load organization products and success': () => async (dispatch) => { await loadOrganizationProducts(params)(dispatch); expect(api.get.mock.calls).toMatchSnapshot('API get call'); expect(apiError).not.toHaveBeenCalled(); }, 'should load organization products and fail': () => (dispatch) => { api.get.mockImplementation(async () => { throw new Error('some-error'); }); return loadOrganizationProducts(params)(dispatch); }, }; describe('OrganizationProducts actions', () => { beforeEach(() => { orgId.mockImplementation(() => 'some-org-id'); api.get.mockImplementation(async () => ({ data: { results: [{ id: 'some-id' }], }, })); }); afterEach(() => { jest.resetAllMocks(); jest.restoreAllMocks(); jest.resetModules(); }); testActionSnapshotWithFixtures(fixtures); });
Version data entries
45 entries across 45 versions & 1 rubygems