Add spec for timeRange reducer
parent
b794ade83b
commit
d1252cf90b
|
@ -0,0 +1,31 @@
|
|||
import reducer from 'src/data_explorer/reducers/timeRange';
|
||||
|
||||
import {
|
||||
setTimeRange,
|
||||
} from 'src/data_explorer/actions/view';
|
||||
|
||||
const noopAction = () => {
|
||||
return {type: 'NOOP'};
|
||||
}
|
||||
|
||||
describe('DataExplorer.Reducers.TimeRange', () => {
|
||||
it('it sets the default timeRange', () => {
|
||||
const state = reducer(undefined, noopAction());
|
||||
const expected = {
|
||||
lower: 'now() - 15m',
|
||||
upper: null,
|
||||
};
|
||||
|
||||
expect(state).to.deep.equal(expected);
|
||||
});
|
||||
|
||||
it('it can set the time range', () => {
|
||||
const timeRange = {
|
||||
lower: 'now() - 5m',
|
||||
upper: null,
|
||||
};
|
||||
const expected = reducer(undefined, setTimeRange(timeRange));
|
||||
|
||||
expect(timeRange).to.deep.equal(expected);
|
||||
});
|
||||
});
|
|
@ -1,6 +1,11 @@
|
|||
import update from 'react-addons-update';
|
||||
|
||||
export default function timeRange(state = {}, action) {
|
||||
const initialState = {
|
||||
upper: null,
|
||||
lower: 'now() - 15m',
|
||||
};
|
||||
|
||||
export default function timeRange(state = initialState, action) {
|
||||
switch (action.type) {
|
||||
case 'SET_TIME_RANGE': {
|
||||
const {upper, lower} = action.payload;
|
||||
|
|
Loading…
Reference in New Issue