Redux 摩卡
Redux 非常實用,因此單元測試非常簡單。
行動創造者:
export function showSidebar () {
return {
type: 'SHOW_SIDEBAR'
}
}
動作建立者單元測試:
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)
})
})