aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/__tests__/ducks/eventLogSpec.js
blob: 1c993734e55bb9c48bb94416ba0b0a1d2a5d8413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
        })
    })
})