import reducer, {defaultState} from 'src/logs/reducers'
import {setTimeWindow} 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 actual = reducer(defaultState, setTimeWindow(expected))
    expect(actual.timeWindow).toBe(expected)
  })
})

import reducer, {defaultState} from 'src/logs/reducers'
import {setTimeWindow, setTimeMarker, setTimeBounds} from 'src/logs/actions'

describe('Logs.Reducers', () => {
  it('can set a time window', () => {
    const actionPayload = {
      windowOption: '10m',
      seconds: 600,
    }

    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)
  })
})

Add Tests for new time range reducers
Add Tests for new time range reducers

Co-authored-by: Alex Paxton <bbdfaa9e47dc3439aa28f1fb2e87c12d0b156815@gmail.com>
Co-authored-by: Daniel Campbell <821887c588844d83343e7d6ba83259f50689d18c@gmail.com>
