Sha256: 446f19a1cb2f21b0dbfa8bdedf616604730de18de8477d4b040a7e42fe771687

Contents?: true

Size: 1.66 KB

Versions: 79

Compression:

Stored size: 1.66 KB

Contents

import React from 'react';
import { IntegrationTestHelper } from '@theforeman/test';
import * as API from 'foremanReact/redux/API';
import { noop } from 'foremanReact/common/helpers';
import SyncButton from '../index';
import { successResponse } from './SyncButtonFixtures';
import {
  INVENTORY_SYNC,
  INVENTORY_SYNC_TASK_UPDATE,
} from '../SyncButtonConstants';

jest.spyOn(API, 'post');
jest.spyOn(API, 'get');

describe('SyncButton integration test', () => {
  it('Successful task was triggered on the server resulting in an info toast and polling on the task', async () => {
    API.post.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
      if (key === INVENTORY_SYNC) {
        handleSuccess(successResponse);
      }
      return { type: 'API_POST', ...action };
    });
    API.get.mockImplementation(({ handleSuccess = noop, key, ...action }) => {
      if (key === INVENTORY_SYNC_TASK_UPDATE) {
        handleSuccess(
          {
            data: {
              endedAt: '2021-03-22T15:59:02.468+02:00',
              output: {
                host_statuses: {
                  sync: 0,
                  disconnect: 2,
                },
              },
              result: 'success',
            },
          },
          jest.fn
        );
      }
      return { type: 'API_GET', ...action };
    });

    const integrationTestHelper = new IntegrationTestHelper();
    const wrapper = integrationTestHelper.mount(<SyncButton />);
    const instance = wrapper.find('SyncButton').instance();
    instance.props.handleSync();
    await IntegrationTestHelper.flushAllPromises();
    integrationTestHelper.takeActionsSnapshot('handleSync was called');
  });
});

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
foreman_rh_cloud-11.0.3 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.59 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-11.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-11.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-11.0.0 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.58 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-10.0.2 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.57 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-10.0.1 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.56 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.55 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.54 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.53 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-8.0.52 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-9.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-8.0.51 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-7.0.48 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-7.0.47 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
foreman_rh_cloud-8.0.50 webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js