Sha256: 4b98b62880583915048b71f49afa9709f627a38180e039076777578f1bc79b04

Contents?: true

Size: 1.27 KB

Versions: 11

Compression:

Stored size: 1.27 KB

Contents

import { testActionSnapshotWithFixtures } from '../../../move_to_pf/test-utils/testHelpers';
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': {
    action: () => loadOrganizationProducts(params),
    test: () => {
      expect(api.get.mock.calls).toMatchSnapshot();
      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

11 entries across 11 versions & 1 rubygems

Version Path
katello-3.11.2 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.2 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.1.1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.11.1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.11.0 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.11.0.rc2 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.11.0.rc1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.0 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.0.rc1.1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js
katello-3.10.0.rc1 webpack/redux/OrganizationProducts/__tests__/OrganizationProductsActions.test.js