client/src/reducers/__tests__/miscReducer.test.js
author ymh <ymh.work@gmail.com>
Tue, 29 Mar 2022 11:23:56 +0200
changeset 211 244a90638e80
parent 168 ea92f4fe783d
permissions -rw-r--r--
Added tag 0.2.3 for changeset 3de92ddba2de


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)
  });

});