client/src/reducers/__tests__/miscReducer.test.js
author ymh <ymh.work@gmail.com>
Mon, 08 Oct 2018 18:35:47 +0200
changeset 168 ea92f4fe783d
permissions -rw-r--r--
- move SlateEditor and dependencies to its own folder - remove Immutable - remove redux-persist-immutable - remobe redux-immutable - update libraries - added tests on store manipulations (accessor and reducers)


import { autoSubmit, online } from '../miscReducer';
import * as types from '../../constants/actionTypes';


describe('misc reducer autosubmit', () => {

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

  it('should handle USER_TOGGLE_AUTO_SUBMIT true', () => {
    expect(
      autoSubmit(false, {
        type: types.USER_TOGGLE_AUTO_SUBMIT,
        value: true
      })
    ).toEqual(true)
  });

  it('should handle USER_TOGGLE_AUTO_SUBMIT false', () => {
    expect(
      autoSubmit(true, {
        type: types.USER_TOGGLE_AUTO_SUBMIT,
        value: false
      })
    ).toEqual(false)
  });

});



describe('misc reducer online', () => {

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

  it('should handle STATUS_ONLINE', () => {
    expect(
      online(false, {
        type: types.STATUS_ONLINE
      })
    ).toEqual(true)
  });

  it('should handle STATUS_OFFLINE', () => {
    expect(
      online(true, {
        type: types.STATUS_OFFLINE
      })
    ).toEqual(false)
  });

});