mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 07:08:10 +00:00
[web] Add tests for reducors of options and modal.
This commit is contained in:
parent
4e8b8bf2ce
commit
7784d7cdd0
25
web/src/js/__tests__/ducks/optionsSpec.js
Normal file
25
web/src/js/__tests__/ducks/optionsSpec.js
Normal file
@ -0,0 +1,25 @@
|
||||
jest.mock('../../utils')
|
||||
|
||||
import reduceOptions, * as OptionsActions from '../../ducks/options'
|
||||
|
||||
describe('option reducer', () => {
|
||||
it('should return initial state', () => {
|
||||
expect(reduceOptions(undefined, {})).toEqual({})
|
||||
})
|
||||
|
||||
it('should handle receive action', () => {
|
||||
let action = { type: OptionsActions.RECEIVE, data: 'foo' }
|
||||
expect(reduceOptions(undefined, action)).toEqual('foo')
|
||||
})
|
||||
|
||||
it('should handle update action', () => {
|
||||
let action = {type: OptionsActions.UPDATE, data: {id: 1} }
|
||||
expect(reduceOptions(undefined, action)).toEqual({id: 1})
|
||||
})
|
||||
})
|
||||
|
||||
describe('option actions', () => {
|
||||
it('should be possible to update option', () => {
|
||||
expect(reduceOptions(undefined, OptionsActions.update())).toEqual({})
|
||||
})
|
||||
})
|
25
web/src/js/__tests__/ducks/ui/modalSpec.js
Normal file
25
web/src/js/__tests__/ducks/ui/modalSpec.js
Normal file
@ -0,0 +1,25 @@
|
||||
import reduceModal, * as ModalActions from '../../../ducks/ui/modal'
|
||||
|
||||
describe('modal reducer', () => {
|
||||
let state = undefined
|
||||
|
||||
it('should return the initial state', () => {
|
||||
expect(reduceModal(undefined, {})).toEqual(
|
||||
{ activeModal: undefined }
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle setActiveModal action', () => {
|
||||
state = reduceModal(undefined, ModalActions.setActiveModal('foo'))
|
||||
expect(state).toEqual(
|
||||
{ activeModal: 'foo' }
|
||||
)
|
||||
})
|
||||
|
||||
it('should handle hideModal action', () => {
|
||||
state = reduceModal(state, ModalActions.hideModal())
|
||||
expect(state).toEqual(
|
||||
{ activeModal: undefined }
|
||||
)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user