Sha256: a902c5e38dcf06c2da50bf6d3c9683c3757f21073d8200e70b1fa10331bcf570

Contents?: true

Size: 1.43 KB

Versions: 12

Compression:

Stored size: 1.43 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import API from 'foremanReact/API';
import {
  startPolling,
  stopPolling,
  fetchLogs,
  setActiveTab,
  downloadReports,
  toggleFullScreen,
} from '../DashboardActions';
import {
  pollingProcessID,
  serverMock,
  activeTab,
  accountID,
} from '../Dashboard.fixtures';
import { rhCloudStateWrapper } from '../../../../ForemanRhCloudTestHelpers';

jest.mock('foremanReact/API');
API.get.mockImplementation(() => serverMock);

const runWithGetState = (state, action, params) => dispatch => {
  const getState = () => rhCloudStateWrapper({ dashboard: state });
  action(params)(dispatch, getState);
};

const fixtures = {
  'should startPolling': () => startPolling(accountID, pollingProcessID),
  'should fetchLogs': () =>
    runWithGetState({ activeTab: 'uploads' }, fetchLogs, accountID),
  'should stopPolling': () => stopPolling(accountID, pollingProcessID),
  'should setActiveTab': () => setActiveTab(accountID, activeTab),
  'should downloadReports': () => downloadReports(accountID),
  'should toggleFullScreen': () =>
    runWithGetState({ activeTab: 'reports' }, toggleFullScreen, accountID),
};

describe('Dashboard actions', () => {
  const { location } = window;

  beforeAll(() => {
    delete window.location;
    window.location = { href: jest.fn() };
  });

  afterAll(() => {
    window.location = location;
  });

  return testActionSnapshotWithFixtures(fixtures);
});

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.17 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.16 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.15 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-3.0.14 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.14 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.13.1 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.13 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.12 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.11 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.10 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.9 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-2.0.8 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js