diff options
author | Matthew Shao <me@matshao.com> | 2017-03-22 18:32:28 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-03-22 18:32:28 +0800 |
commit | 20d3ae98e08d4a10a9d54eb6730253208d34444d (patch) | |
tree | 5cd843e3f8222973d5cd8ecfec19df0ca7857f15 /web/src | |
parent | ab2fcbef8dceb5abc97f7e73638629ded606daa6 (diff) | |
download | mitmproxy-20d3ae98e08d4a10a9d54eb6730253208d34444d.tar.gz mitmproxy-20d3ae98e08d4a10a9d54eb6730253208d34444d.tar.bz2 mitmproxy-20d3ae98e08d4a10a9d54eb6730253208d34444d.zip |
[web] Reach 100% coverage for ducks/eventLog.js
Diffstat (limited to 'web/src')
-rw-r--r-- | web/src/js/__tests__/ducks/eventLogSpec.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/web/src/js/__tests__/ducks/eventLogSpec.js b/web/src/js/__tests__/ducks/eventLogSpec.js new file mode 100644 index 00000000..d4d4f37a --- /dev/null +++ b/web/src/js/__tests__/ducks/eventLogSpec.js @@ -0,0 +1,40 @@ +jest.unmock('../../ducks/eventLog') + +import reduceEventLog, * as eventLogActions from '../../ducks/eventLog' +import reduceStore from '../../ducks/utils/store' + +describe('event log reducer', () => { + it('should return initial state', () => { + expect(reduceEventLog(undefined, {})).toEqual({ + visible: false, + filters: { debug: false, info: true, web: true, warn: true, error: true }, + ...reduceStore(undefined, {}), + }) + }) + + it('should be possible to toggle filter', () => { + let state = reduceEventLog(undefined, eventLogActions.add('foo')) + expect(reduceEventLog(state, eventLogActions.toggleFilter('info'))).toEqual({ + visible: false, + filters: { ...state.filters, info: false}, + ...reduceStore(state, {}) + }) + }) + + it('should be possible to toggle visibility', () => { + let state = reduceEventLog(undefined, {}) + expect(reduceEventLog(state, eventLogActions.toggleVisibility())).toEqual({ + visible: true, + filters: {...state.filters}, + ...reduceStore(undefined, {}) + }) + }) + + it('should be possible to add message', () => { + let state = reduceEventLog(undefined, eventLogActions.add('foo')) + expect(state.visible).toBeFalsy() + expect(state.filters).toEqual({ + debug: false, info: true, web: true, warn: true, error: true + }) + }) +}) |