Sha256: 2f44b7b98eb78fddd5afd7de9fef802b0a3c83993505b5e5fcb2a9c67b44070b

Contents?: true

Size: 968 Bytes

Versions: 9

Compression:

Stored size: 968 Bytes

Contents

import { testActionSnapshotWithFixtures } from '@theforeman/test';
import API from 'foremanReact/API';
import { handleSync } from '../SyncButtonActions';
import { successResponse } from './SyncButtonFixtures';

jest.mock('foremanReact/API');
API.post.mockImplementation(async () => successResponse);

const fixtures = {
  'should handleSync': () => handleSync(),
  'should handleSync with error message': () => {
    API.post.mockImplementationOnce(() =>
      Promise.reject(new Error('Network error!'))
    );

    return handleSync();
  },
  'should handleSync with custom error message': () => {
    API.post.mockImplementationOnce(() => {
      const customError = new Error('Server error!');
      customError.response = {
        data: { message: 'Custom error to display in a toast' },
      };
      return Promise.reject(customError);
    });

    return handleSync();
  },
};

describe('SyncButton actions', () => testActionSnapshotWithFixtures(fixtures));

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.18.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.18 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.17 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.16 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.15 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-3.0.14 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.14 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.13.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-2.0.13 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js