Sha256: eca1e8cb1f7099bd4b636627e588f2ce3dac6e966b153ca9c990bbe8be8f0cb1

Contents?: true

Size: 1.8 KB

Versions: 63

Compression:

Stored size: 1.8 KB

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import { API } from 'foremanReact/redux/API';
import {
  cancelTaskRequest,
  resumeTaskRequest,
  forceCancelTaskRequest,
  unlockTaskRequest,
} from './';

jest.mock('foremanReact/components/common/table', () => ({
  getTableItemsAction: jest.fn(controller => controller),
}));

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

const task = ['some-id', 'some-name'];

const fixtures = {
  'should cancelTaskRequest and succeed': () => cancelTaskRequest(...task),
  'should cancelTaskRequest and fail': () => {
    API.post.mockImplementation(() =>
      Promise.reject(new Error('Network Error'))
    );
    return cancelTaskRequest(...task);
  },

  'should resumeTaskRequest and succeed': () => {
    API.post.mockImplementation(() => ({ data: 'some-data' }));
    return resumeTaskRequest(...task);
  },
  'should resumeTaskRequest and fail': () => {
    API.post.mockImplementation(() =>
      Promise.reject(new Error('Network Error'))
    );
    return resumeTaskRequest(...task);
  },
  'should forceCancelTaskRequest and succeed': () => {
    API.post.mockImplementation(() => ({ data: 'some-data' }));
    return forceCancelTaskRequest(...task);
  },
  'should forceCancelTaskRequest and fail': () => {
    API.post.mockImplementation(() =>
      Promise.reject(new Error('Network Error'))
    );
    return forceCancelTaskRequest(...task);
  },
  'should unlockTaskRequest and succeed': () => {
    API.post.mockImplementation(() => ({ data: 'some-data' }));
    return unlockTaskRequest(...task);
  },
  'should unlockTaskRequest and fail': () => {
    API.post.mockImplementation(() =>
      Promise.reject(new Error('Network Error'))
    );
    return forceCancelTaskRequest(...task);
  },
};
describe('Tasks actions', () => {
  testActionSnapshotWithFixtures(fixtures);
});

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
foreman-tasks-3.0.0 webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js
foreman-tasks-2.0.2 webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js
foreman-tasks-2.0.1 webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js