influxdb/ui/spec/data_explorer/reducers/uiSpec.js

41 lines
838 B
JavaScript
Raw Normal View History

2017-03-30 22:29:43 +00:00
import reducer from 'src/data_explorer/reducers/ui'
2017-02-13 23:16:54 +00:00
import {
addQuery,
deleteQuery,
2017-03-30 22:29:43 +00:00
} from 'src/data_explorer/actions/view'
2017-02-13 23:16:54 +00:00
const noopAction = () => {
2017-03-30 22:29:43 +00:00
return {type: 'NOOP'}
2017-02-13 23:16:54 +00:00
}
2017-03-30 22:29:43 +00:00
let state
2017-02-13 23:16:54 +00:00
describe('DataExplorer.Reducers.UI', () => {
it('it sets the default state for UI', () => {
2017-03-30 22:29:43 +00:00
const actual = reducer(state, noopAction())
2017-02-13 23:16:54 +00:00
const expected = {
queryIDs: [],
2017-03-30 22:29:43 +00:00
}
2017-02-13 23:16:54 +00:00
2017-03-30 22:29:43 +00:00
expect(actual).to.deep.equal(expected)
})
2017-02-13 23:16:54 +00:00
it('it can add a query', () => {
2017-03-30 22:29:43 +00:00
const actual = reducer(state, addQuery())
expect(actual.queryIDs.length).to.equal(1)
})
2017-02-13 23:16:54 +00:00
it('it can delete a query', () => {
2017-03-30 22:29:43 +00:00
const queryID = '123'
state = {queryIDs: ['456', queryID]}
2017-02-13 23:16:54 +00:00
2017-03-30 22:29:43 +00:00
const actual = reducer(state, deleteQuery(queryID))
2017-02-13 23:16:54 +00:00
const expected = {
queryIDs: ['456'],
2017-03-30 22:29:43 +00:00
}
2017-02-13 23:16:54 +00:00
2017-03-30 22:29:43 +00:00
expect(actual).to.deep.equal(expected)
})
})