mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 11:03:13 +00:00
[web] Reach 100% coverage for ducks/eventLog.js
This commit is contained in:
parent
ab2fcbef8d
commit
20d3ae98e0
40
web/src/js/__tests__/ducks/eventLogSpec.js
Normal file
40
web/src/js/__tests__/ducks/eventLogSpec.js
Normal file
@ -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
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user