Sha256: e20e9f1427b0f3b2ace65cb7ee0c4cbc3d543a939f3f710155c9f7db5942b43e

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import API from 'foremanReact/API';
import {
  getInsightsSyncSettings,
  setInsightsSyncEnabled,
} from '../InsightsSettingsActions';
import { rhCloudStateWrapper } from '../../../../ForemanRhCloudTestHelpers';

const serverMock = {
  data: { insightsSyncEnabled: true },
};

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

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

const fixtures = {
  'should generate INSIGHTS_SYNC_SETTINGS_GET_SUCCESS action': () =>
    runWithGetState({ settings: {} }, getInsightsSyncSettings, {}),
  'should generate INSIGHTS_SYNC_SETTING_SET action': () =>
    runWithGetState(
      { settings: { insightsSyncEnabled: false } },
      setInsightsSyncEnabled,
      true
    ),
};

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

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

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

  return testActionSnapshotWithFixtures(fixtures);
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.12 webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js
foreman_rh_cloud-2.0.11 webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js
foreman_rh_cloud-2.0.10 webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js