Sha256: 9da2bc7f56f7a38fcf5ab10dcd0caa9cabb91f478d0a4d74a6d2e81fd6777c58

Contents?: true

Size: 1.41 KB

Versions: 82

Compression:

Stored size: 1.41 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import { API } from 'foremanReact/redux/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/redux/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 { open } = window;

  beforeAll(() => {
    delete window.open;
    window.open = jest.fn();
  });

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

  return testActionSnapshotWithFixtures(fixtures);
});

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.18 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js
foreman_rh_cloud-3.0.17 webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js