Sha256: 418e063c63f30797e67d70579634b684386b7777de8300bae613ae1b81d76526

Contents?: true

Size: 1.3 KB

Versions: 84

Compression:

Stored size: 1.3 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import API from 'foremanReact/redux/API';
import {
  fetchInsights,
  setSelectAllAlert,
  selectByIds,
  setSelectAll,
  selectAll,
  clearAllSelection,
} from '../InsightsTableActions';
import { hits } from './fixtures';

jest.mock('foremanReact/redux/API', () => jest.fn());
API.get = jest.fn(({ handleSuccess, ...action }) => {
  handleSuccess({ data: { hits } });
  return { type: 'get', ...action };
});

const runWithGetState = (state, action, params) => dispatch => {
  const getState = () => ({
    router: {
      location: {
        query: {
          page: '1',
          per_page: '7',
          search: '',
          sort_by: '',
          sort_order: '',
          select_all: 'true',
        },
      },
    },
  });
  action(params)(dispatch, getState);
};

const fixtures = {
  'should fetchInsights': () =>
    runWithGetState({}, fetchInsights, { page: 2, perPage: 7 }),
  'should setSelectAllAlert true': () => setSelectAllAlert(true),
  'should selectByIds': () => selectByIds({ 1: true, 5: true }),
  'should setSelectAll false': () => setSelectAll(false),
  'should selectAll': () => selectAll(),
  'should clearAllSelection': () => clearAllSelection(),
};

describe('insights table actions', () =>
  testActionSnapshotWithFixtures(fixtures));

Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.1.0 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-10.0.3 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-11.0.3 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.59 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-11.0.2 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-11.0.1 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-11.0.0 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.58 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-10.0.2 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.57 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-10.0.1 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.56 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.55 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.54 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.53 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.52 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-8.0.52 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-9.0.51 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-8.0.51 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js
foreman_rh_cloud-7.0.48 webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js