Sha256: cea3d96ffdb4edc550dbf04c69d2d20650897a776dccc8f71e97844a973360c2

Contents?: true

Size: 1.82 KB

Versions: 128

Compression:

Stored size: 1.82 KB

Contents

import * as types from '../UpstreamSubscriptionsConstants';

import {
  initialState,
  loadingState,
  requestSuccessResponse,
  taskSuccessResponse,
  successState,
  errorState, saveSuccessState, initialSaveState, saveErrorState,
} from './upstreamSubscriptions.fixtures';
import reducer from '../UpstreamSubscriptionsReducer';

describe('upstream subscriptions reducer', () => {
  const errorResult = {
    response: {
      data: 'Unable to process request.',
    },
  };

  it('should return the initial state', () => {
    expect(reducer(undefined, {})).toEqual(initialState);
  });

  it('should keep loading state on UPSTREAM_SUBSCRIPTIONS_REQUEST', () => {
    expect(reducer(initialState, {
      type: types.UPSTREAM_SUBSCRIPTIONS_REQUEST,
    })).toEqual(loadingState);
  });

  it('should flatten subscriptions response UPSTREAM_SUBSCRIPTIONS_SUCCESS', () => {
    expect(reducer(initialState, {
      type: types.UPSTREAM_SUBSCRIPTIONS_SUCCESS,
      response: requestSuccessResponse,
    })).toEqual(successState);
  });

  it('should have error on UPSTREAM_SUBSCRIPTIONS_FAILURE', () => {
    expect(reducer(initialState, {
      type: types.UPSTREAM_SUBSCRIPTIONS_FAILURE,
      payload: {
        message: 'Unable to process request.',
      },
    })).toEqual(errorState);
  });

  it('should flatten response SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS', () => {
    expect(reducer(initialSaveState, {
      type: types.SAVE_UPSTREAM_SUBSCRIPTIONS_SUCCESS,
      response: taskSuccessResponse,
    })).toEqual(saveSuccessState);
  });

  it('should have error on SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE', () => {
    expect(reducer(initialSaveState, {
      type: types.SAVE_UPSTREAM_SUBSCRIPTIONS_FAILURE,
      payload: {
        message: 'Unable to process request.',
        result: errorResult,
      },
    })).toEqual(saveErrorState);
  });
});

Version data entries

128 entries across 128 versions & 1 rubygems

Version Path
katello-4.15.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.15.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.0.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.0.rc1.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.14.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.13.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.13.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.12.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.13.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.12.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.12.0.rc3 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.12.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.12.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.11.1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.11.0 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.11.0.rc2 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js
katello-4.11.0.rc1 webpack/scenes/Subscriptions/UpstreamSubscriptions/__tests__/UpstreamSubscriptionsReducer.test.js