Sha256: 5750e7975e55c5504f2fdd815a7d08f058bf282c908e79068c24e580bea792b2

Contents?: true

Size: 1.96 KB

Versions: 44

Compression:

Stored size: 1.96 KB

Contents

import Immutable from 'seamless-immutable';
import { testReducerSnapshotWithFixtures } from '@theforeman/test';
import {
  TASKS_TABLE_ID,
  TASKS_TABLE_SET_SORT,
  TASKS_TABLE_SET_PAGINATION,
  SELECT_ROWS,
  UNSELECT_ROWS,
  UNSELECT_ALL_ROWS,
  UPDATE_CLICKED,
  SELECT_ALL_ROWS,
  OPEN_SELECT_ALL,
} from '../TasksTableConstants';
import reducer from '../TasksTableReducer';

const fixtures = {
  'should return the initial state': {},
  'should handle TASKS_TABLE_SUCCESS': {
    action: {
      type: `${TASKS_TABLE_ID}_SUCCESS`,
      response: {
        subtotal: 120,
        page: 3,
        per_page: 12,
      },
    },
  },
  'should handle TASKS_TABLE_SET_SORT': {
    action: {
      type: TASKS_TABLE_SET_SORT,
      payload: { by: 'a', order: 'b' },
    },
  },

  'should handle TASKS_TABLE_SET_PAGINATION': {
    action: {
      type: TASKS_TABLE_SET_PAGINATION,
      payload: { page: 4, perPage: 7 },
    },
  },
  'should handle SELECT_ROWS': {
    action: {
      type: SELECT_ROWS,
      payload: [1, 2, 3, 4, 5, 6, 7],
    },
  },
  'should handle UNSELECT_ROWS': {
    action: {
      type: UNSELECT_ROWS,
      payload: [{ id: 4 }],
    },
  },
  'should handle UNSELECT_ALL_ROWS': {
    action: {
      type: UNSELECT_ALL_ROWS,
    },
  },
  'should handle UPDATE_CLICKED': {
    action: {
      type: UPDATE_CLICKED,
      payload: { clicked: 'task' },
    },
  },
  'should handle SELECT_ALL_ROWS': {
    action: {
      type: SELECT_ALL_ROWS,
      payload: { clicked: 'task' },
    },
  },
  'should handle OPEN_SELECT_ALL': {
    action: {
      type: OPEN_SELECT_ALL,
    },
  },
  'should handle UNSELECT_ROWS with all rows selected': {
    state: Immutable({
      tasksTableQuery: { allRowsSelected: true, selectedRows: [3, 4, 5] },
    }),
    action: {
      type: UNSELECT_ROWS,
      payload: { id: [4], results: [{ id: 3 }, { id: 4 }, { id: 5 }] },
    },
  },
};

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

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
foreman-tasks-10.0.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-10.0.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.2.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.2.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.2.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.2.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.1.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.0.4 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.1.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.0.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.0.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.3.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-9.0.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.2.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.1.4 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.3.2 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.3.1 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.1.3 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.3.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js
foreman-tasks-8.2.0 webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js