Sha256: 72180228c15d4629c824d088e142d3a79c48dd12bdae61108fcf34f7fddf53e4

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import { API } from 'foremanReact/redux/API';
import {
  taskReloadStop,
  taskReloadStart,
  fetchTaskDetails,
  cancelStep,
} from '../TaskDetailsActions';

jest.mock('foremanReact/redux/API');

API.get.mockImplementation(async () => ({ data: 'some-data' }));
API.post.mockImplementation(async () => ({ data: 'some-data' }));

const fixtures = {
  'should start reload': () => taskReloadStart(1),
  'should stop reload': () => taskReloadStop(2),
  'should fetch-task-details and success': () => fetchTaskDetails(),
  'should cancelStep and success': () => cancelStep('task-id', 'step-id'),

  'should fetch-task-details and fail': () => {
    API.get.mockImplementationOnce(() =>
      Promise.reject(new Error('Network Error'))
    );
    return fetchTaskDetails();
  },
  'should cancelStep and fail': () => {
    API.post.mockImplementationOnce(() =>
      Promise.reject(new Error('Network Error'))
    );
    return cancelStep('task-id', 'step-id');
  },
};

describe('TaskDetails - Actions', () =>
  testActionSnapshotWithFixtures(fixtures));

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman-tasks-2.0.3 webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js
foreman-tasks-2.0.2 webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js
foreman-tasks-2.0.1 webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js