Sha256: 00a2523862bf15c1b2c253b8bf81234d1a726f00c8120c7c7698ea56a717a45f

Contents?: true

Size: 984 Bytes

Versions: 5

Compression:

Stored size: 984 Bytes

Contents

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

jest.mock('foremanReact/redux/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

5 entries across 5 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.18.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-3.0.18 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-3.0.17 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-3.0.16 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js
foreman_rh_cloud-3.0.15 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js