Sha256: f16b277dbabfc7b8b5422ae7188f6fa85d6cba10794d7b17f58ccb307fd460f6
Contents?: true
Size: 1.23 KB
Versions: 122
Compression:
Stored size: 1.23 KB
Contents
import { testActionSnapshotWithFixtures } from 'react-redux-test-utils'; import api, { orgId } from '../../../services/api'; import { apiError } from '../../../utils/helpers'; import { loadOrganizationProducts } from '../OrganizationProductsActions'; const params = { search: 'some-search', }; jest.mock('../../../services/api'); jest.mock('../../../utils/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
122 entries across 122 versions & 1 rubygems