Add Tests for new time range reducers

Co-authored-by: Alex Paxton <thealexpaxton@gmail.com>
Co-authored-by: Daniel Campbell <metalwhirlwind@gmail.com>
pull/10616/head
Alex P 2018-07-11 18:52:07 -07:00
parent 04b014ed67
commit 26dd668516
1 changed files with 49 additions and 9 deletions

View File

@ -1,17 +1,57 @@
import reducer, {defaultState} from 'src/logs/reducers'
import {setTimeWindow} from 'src/logs/actions'
import {setTimeWindow, setTimeMarker, setTimeBounds} from 'src/logs/actions'
describe('Logs.Reducers', () => {
it('can set a time window', () => {
const expected = {
timeOption: 'now',
windowOption: '1h',
upper: null,
lower: 'now() - 1h',
seconds: 3600,
const actionPayload = {
windowOption: '10m',
seconds: 600,
}
const actual = reducer(defaultState, setTimeWindow(expected))
expect(actual.timeWindow).toBe(expected)
const expected = {
timeOption: 'now',
windowOption: '10m',
upper: null,
lower: 'now() - 1m',
seconds: 600,
}
const actual = reducer(defaultState, setTimeWindow(actionPayload))
expect(actual.timeRange).toEqual(expected)
})
it('can set a time marker', () => {
const actionPayload = {
timeOption: '2018-07-10T22:22:21.769Z',
}
const expected = {
timeOption: '2018-07-10T22:22:21.769Z',
windowOption: '1m',
upper: null,
lower: 'now() - 1m',
seconds: 60,
}
const actual = reducer(defaultState, setTimeMarker(actionPayload))
expect(actual.timeRange).toEqual(expected)
})
it('can set the time bounds', () => {
const payload = {
upper: '2018-07-10T22:20:21.769Z',
lower: '2018-07-10T22:22:21.769Z',
}
const expected = {
timeOption: 'now',
windowOption: '1m',
upper: '2018-07-10T22:20:21.769Z',
lower: '2018-07-10T22:22:21.769Z',
seconds: 60,
}
const actual = reducer(defaultState, setTimeBounds(payload))
expect(actual.timeRange).toEqual(expected)
})
})