diff options
| author | Matthew Shao <me@matshao.com> | 2017-07-01 08:46:04 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-01 08:46:04 -0500 |
| commit | f3231ed758324a7de465ee5a377f9c40b0a8df34 (patch) | |
| tree | 3979c67de95b398e8d0c89034feee60a0d0a3bb6 /web/src/js/__tests__/ducks | |
| parent | 321352ef0bc1911d49c8b6f8537674b03fa92f70 (diff) | |
| parent | aad0b95cbe65e97574d49f3933002d347470d1ef (diff) | |
| download | mitmproxy-f3231ed758324a7de465ee5a377f9c40b0a8df34.tar.gz mitmproxy-f3231ed758324a7de465ee5a377f9c40b0a8df34.tar.bz2 mitmproxy-f3231ed758324a7de465ee5a377f9c40b0a8df34.zip | |
Merge pull request #2416 from MatthewShao/mitmweb-options
[WIP] [web] Mitmweb options editor UI
Diffstat (limited to 'web/src/js/__tests__/ducks')
| -rw-r--r-- | web/src/js/__tests__/ducks/optionsSpec.js | 25 | ||||
| -rw-r--r-- | web/src/js/__tests__/ducks/tutils.js | 6 | ||||
| -rw-r--r-- | web/src/js/__tests__/ducks/ui/modalSpec.js | 25 |
3 files changed, 55 insertions, 1 deletions
diff --git a/web/src/js/__tests__/ducks/optionsSpec.js b/web/src/js/__tests__/ducks/optionsSpec.js new file mode 100644 index 00000000..62019715 --- /dev/null +++ b/web/src/js/__tests__/ducks/optionsSpec.js @@ -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({}) + }) +}) diff --git a/web/src/js/__tests__/ducks/tutils.js b/web/src/js/__tests__/ducks/tutils.js index 2a79ede0..9b92e676 100644 --- a/web/src/js/__tests__/ducks/tutils.js +++ b/web/src/js/__tests__/ducks/tutils.js @@ -32,6 +32,9 @@ export function TStore(){ }, header: { tab: 'Start' + }, + modal: { + activeModal: undefined } }, settings: { @@ -47,7 +50,8 @@ export function TStore(){ sort: { desc: true, column: 'PathColumn' - } + }, + view: [ tflow ] }, connection: { state: ConnectionState.ESTABLISHED diff --git a/web/src/js/__tests__/ducks/ui/modalSpec.js b/web/src/js/__tests__/ducks/ui/modalSpec.js new file mode 100644 index 00000000..30c39760 --- /dev/null +++ b/web/src/js/__tests__/ducks/ui/modalSpec.js @@ -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 } + ) + }) +}) |
