redux Redux + Mocha


Example

Redux is very functional, so unit testing is very straightforward.

Action creator:

export function showSidebar () {
  return {
    type: 'SHOW_SIDEBAR'
  }
}

Action creators unit test:

import expect from 'expect'
import actions from './actions'
import * as type from './constants'

describe('actions', () => {
  it('should show sidebar', () => {
    const expectedAction = {
      type: type.SHOW_SIDEBAR
    }
    expect(actions.showSidebar()).toEqual(expectedAction)
  })
})