Sha256: d4b8a721ac348b21227226fefd3922690bc87cd0543db76f26d3747bd801e12f

Contents?: true

Size: 1.61 KB

Versions: 65

Compression:

Stored size: 1.61 KB

Contents

import { testReducerSnapshotWithFixtures } from '@theforeman/test';

import reducer, { initialState } from '../AnsibleRolesSwitcherReducer';
import { ansibleRolesLong } from '../__fixtures__/ansibleRolesData.fixtures';

import {
  successPayload,
  successState,
  errorPayload,
} from '../__fixtures__/ansibleRolesSwitcherReducer.fixtures';

import {
  ANSIBLE_ROLES_REQUEST,
  ANSIBLE_ROLES_SUCCESS,
  ANSIBLE_ROLES_FAILURE,
  ANSIBLE_ROLES_ADD,
  ANSIBLE_ROLES_REMOVE,
} from '../AnsibleRolesSwitcherConstants';

const fixtures = {
  'should return initial state': {
    state: initialState,
    action: {
      type: undefined,
      payload: {},
    },
  },
  'should start loading on Ansible roles request': {
    state: initialState,
    action: {
      type: ANSIBLE_ROLES_REQUEST,
    },
  },
  'should stop loading on Ansible roles success': {
    state: initialState.set('loading', true),
    action: {
      type: ANSIBLE_ROLES_SUCCESS,
      payload: successPayload,
    },
  },
  'should stop loading on Ansible roles error': {
    state: initialState.set('loading', true),
    action: {
      type: ANSIBLE_ROLES_FAILURE,
      payload: { error: errorPayload },
    },
  },
  'should add Ansible role to assigned': {
    state: successState,
    action: {
      type: ANSIBLE_ROLES_ADD,
      payload: { role: ansibleRolesLong[8] },
    },
  },
  'should remove Ansible role from assigned': {
    state: successState,
    action: {
      type: ANSIBLE_ROLES_REMOVE,
      payload: { role: ansibleRolesLong[5] },
    },
  },
};

describe('AnsibleRolesSwitcherReducer', () =>
  testReducerSnapshotWithFixtures(reducer, fixtures));

Version data entries

65 entries across 65 versions & 1 rubygems

Version Path
foreman_ansible-6.3.2 webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js
foreman_ansible-6.3.1 webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js
foreman_ansible-6.4.1 webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js
foreman_ansible-6.4.0 webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js
foreman_ansible-6.3.0 webpack/components/AnsibleRolesSwitcher/__tests__/AnsibleRolesSwitcherReducer.test.js