2018-03-12 17:11:05 +00:00
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
import {TableOptions} from 'src/dashboards/components/TableOptions'
|
|
|
|
|
|
|
|
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
|
|
|
|
import GraphOptionsTimeFormat from 'src/dashboards/components/GraphOptionsTimeFormat'
|
|
|
|
import GraphOptionsTimeAxis from 'src/dashboards/components/GraphOptionsTimeAxis'
|
|
|
|
import GraphOptionsSortBy from 'src/dashboards/components/GraphOptionsSortBy'
|
|
|
|
import GraphOptionsTextWrapping from 'src/dashboards/components/GraphOptionsTextWrapping'
|
|
|
|
import GraphOptionsCustomizeColumns from 'src/dashboards/components/GraphOptionsCustomizeColumns'
|
2018-03-15 03:57:55 +00:00
|
|
|
import ThresholdsList from 'src/shared/components/ThresholdsList'
|
2018-03-15 04:20:22 +00:00
|
|
|
import ThresholdsListTypeToggle from 'src/shared/components/ThresholdsListTypeToggle'
|
2018-03-20 01:20:17 +00:00
|
|
|
import GraphOptionsFixFirstColumn from 'src/dashboards/components/GraphOptionsFixFirstColumn'
|
2018-03-12 17:11:05 +00:00
|
|
|
|
|
|
|
import {shallow} from 'enzyme'
|
|
|
|
|
2018-03-17 00:41:28 +00:00
|
|
|
const queryConfigs = [
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
measurement: 'dev',
|
2018-03-17 00:41:28 +00:00
|
|
|
fields: [
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
alias: 'boom',
|
|
|
|
value: 'test',
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
alias: 'again',
|
|
|
|
value: 'again',
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
2018-03-20 01:20:17 +00:00
|
|
|
],
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
measurement: 'prod',
|
2018-03-17 00:41:28 +00:00
|
|
|
fields: [
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
alias: 'boom',
|
|
|
|
value: 'test',
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
alias: 'again',
|
|
|
|
value: 'again',
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
2018-03-20 01:20:17 +00:00
|
|
|
],
|
|
|
|
},
|
2018-03-17 00:41:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
queryConfigs: queryConfigs,
|
|
|
|
handleUpdateTableOptions: () => {},
|
|
|
|
tableOptions: {
|
|
|
|
timeFormat: '',
|
|
|
|
verticalTimeAxis: true,
|
|
|
|
sortBy: {internalName: '', displayName: ''},
|
|
|
|
wrapping: '',
|
|
|
|
columnNames: [],
|
2018-03-20 01:20:17 +00:00
|
|
|
fixFirstColumn: true,
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
|
|
|
onResetFocus: () => {},
|
|
|
|
}
|
|
|
|
|
2018-03-12 17:11:05 +00:00
|
|
|
const setup = (override = {}) => {
|
|
|
|
const props = {
|
2018-03-17 00:41:28 +00:00
|
|
|
...defaultProps,
|
2018-03-12 17:11:05 +00:00
|
|
|
...override,
|
|
|
|
}
|
|
|
|
|
|
|
|
const wrapper = shallow(<TableOptions {...props} />)
|
|
|
|
|
|
|
|
return {wrapper, props}
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Dashboards.Components.TableOptions', () => {
|
2018-03-17 00:41:28 +00:00
|
|
|
describe('getters', () => {
|
|
|
|
describe('computedColumnNames', () => {
|
|
|
|
it('returns the correct column names', () => {
|
|
|
|
const instance = new TableOptions(defaultProps)
|
|
|
|
|
|
|
|
const expected = [
|
|
|
|
{
|
|
|
|
displayName: '',
|
|
|
|
internalName: 'time',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: '',
|
|
|
|
internalName: 'dev.boom',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: '',
|
|
|
|
internalName: 'dev.again',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: '',
|
|
|
|
internalName: 'prod.boom',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: '',
|
|
|
|
internalName: 'prod.again',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
expect(instance.computedColumnNames).toEqual(expected)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2018-03-12 17:11:05 +00:00
|
|
|
describe('rendering', () => {
|
|
|
|
it('should render all components', () => {
|
2018-03-17 00:41:28 +00:00
|
|
|
const queryConfigs = [
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
measurement: 'dev',
|
2018-03-17 00:41:28 +00:00
|
|
|
fields: [
|
|
|
|
{
|
2018-03-20 01:20:17 +00:00
|
|
|
alias: 'boom',
|
|
|
|
value: 'test',
|
2018-03-17 00:41:28 +00:00
|
|
|
},
|
2018-03-20 01:20:17 +00:00
|
|
|
],
|
|
|
|
},
|
2018-03-17 00:41:28 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
const expectedSortOptions = [
|
|
|
|
{
|
|
|
|
key: 'time',
|
|
|
|
text: 'time',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'dev.boom',
|
|
|
|
text: 'dev.boom',
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
2018-03-20 01:20:17 +00:00
|
|
|
const {wrapper} = setup({queryConfigs})
|
2018-03-12 17:11:05 +00:00
|
|
|
const fancyScrollbar = wrapper.find(FancyScrollbar)
|
|
|
|
const graphOptionsTimeFormat = wrapper.find(GraphOptionsTimeFormat)
|
|
|
|
const graphOptionsTimeAxis = wrapper.find(GraphOptionsTimeAxis)
|
|
|
|
const graphOptionsSortBy = wrapper.find(GraphOptionsSortBy)
|
|
|
|
const graphOptionsTextWrapping = wrapper.find(GraphOptionsTextWrapping)
|
2018-03-20 01:20:17 +00:00
|
|
|
const graphOptionsFixFirstColumn = wrapper.find(
|
|
|
|
GraphOptionsFixFirstColumn
|
|
|
|
)
|
2018-03-12 17:11:05 +00:00
|
|
|
const graphOptionsCustomizeColumns = wrapper.find(
|
|
|
|
GraphOptionsCustomizeColumns
|
|
|
|
)
|
2018-03-15 03:57:55 +00:00
|
|
|
const thresholdsList = wrapper.find(ThresholdsList)
|
2018-03-15 04:20:22 +00:00
|
|
|
const thresholdsListTypeToggle = wrapper.find(ThresholdsListTypeToggle)
|
2018-03-12 17:11:05 +00:00
|
|
|
|
2018-03-20 01:20:17 +00:00
|
|
|
expect(graphOptionsSortBy.props().sortByOptions).toEqual(
|
|
|
|
expectedSortOptions
|
|
|
|
)
|
2018-03-17 00:41:28 +00:00
|
|
|
|
2018-03-12 17:11:05 +00:00
|
|
|
expect(fancyScrollbar.exists()).toBe(true)
|
|
|
|
expect(graphOptionsTimeFormat.exists()).toBe(true)
|
|
|
|
expect(graphOptionsTimeAxis.exists()).toBe(true)
|
|
|
|
expect(graphOptionsSortBy.exists()).toBe(true)
|
|
|
|
expect(graphOptionsTextWrapping.exists()).toBe(true)
|
2018-03-20 01:20:17 +00:00
|
|
|
expect(graphOptionsFixFirstColumn.exists()).toBe(true)
|
2018-03-12 17:11:05 +00:00
|
|
|
expect(graphOptionsCustomizeColumns.exists()).toBe(true)
|
2018-03-15 03:57:55 +00:00
|
|
|
expect(thresholdsList.exists()).toBe(true)
|
2018-03-15 04:20:22 +00:00
|
|
|
expect(thresholdsListTypeToggle.exists()).toBe(true)
|
2018-03-12 17:11:05 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|