influxdb/ui/test/dashboards/components/TableOptions.test.tsx

68 lines
2.5 KiB
TypeScript
Raw Normal View History

2018-03-22 20:20:00 +00:00
import {shallow} from 'enzyme'
2018-03-12 17:11:05 +00:00
import React from 'react'
2018-03-22 20:20:00 +00:00
import GraphOptionsCustomizeFields from 'src/dashboards/components/GraphOptionsCustomizeFields'
2018-03-21 22:24:59 +00:00
import GraphOptionsFixFirstColumn from 'src/dashboards/components/GraphOptionsFixFirstColumn'
2018-03-12 17:11:05 +00:00
import GraphOptionsSortBy from 'src/dashboards/components/GraphOptionsSortBy'
2018-03-21 22:24:59 +00:00
import GraphOptionsTimeAxis from 'src/dashboards/components/GraphOptionsTimeAxis'
import GraphOptionsTimeFormat from 'src/dashboards/components/GraphOptionsTimeFormat'
2018-03-22 20:20:00 +00:00
import {TableOptions} from 'src/dashboards/components/TableOptions'
2018-03-21 22:24:59 +00:00
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
2018-03-15 03:57:55 +00:00
import ThresholdsList from 'src/shared/components/ThresholdsList'
import ThresholdsListTypeToggle from 'src/shared/components/ThresholdsListTypeToggle'
2018-03-12 17:11:05 +00:00
const defaultProps = {
handleUpdateTableOptions: () => {},
2018-03-21 23:08:03 +00:00
onResetFocus: () => {},
queryConfigs: [],
tableOptions: {
2018-03-21 23:08:03 +00:00
columnNames: [],
2018-03-22 20:20:00 +00:00
fieldNames: [],
2018-03-21 23:08:03 +00:00
fixFirstColumn: true,
2018-03-22 20:20:00 +00:00
sortBy: {displayName: '', internalName: '', visible: true},
timeFormat: '',
verticalTimeAxis: true,
},
}
2018-03-12 17:11:05 +00:00
const setup = (override = {}) => {
const props = {
...defaultProps,
2018-03-12 17:11:05 +00:00
...override,
}
const wrapper = shallow(<TableOptions {...props} />)
2018-03-24 01:39:45 +00:00
const instance = wrapper.instance() as TableOptions
return {wrapper, instance, props}
2018-03-12 17:11:05 +00:00
}
describe('Dashboards.Components.TableOptions', () => {
describe('rendering', () => {
it('should render all components', () => {
const {wrapper} = setup()
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 graphOptionsFixFirstColumn = wrapper.find(
GraphOptionsFixFirstColumn
)
const graphOptionsCustomizeFields = wrapper.find(
GraphOptionsCustomizeFields
2018-03-12 17:11:05 +00:00
)
2018-03-15 03:57:55 +00:00
const thresholdsList = wrapper.find(ThresholdsList)
const thresholdsListTypeToggle = wrapper.find(ThresholdsListTypeToggle)
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(graphOptionsFixFirstColumn.exists()).toBe(true)
expect(graphOptionsCustomizeFields.exists()).toBe(true)
2018-03-15 03:57:55 +00:00
expect(thresholdsList.exists()).toBe(true)
expect(thresholdsListTypeToggle.exists()).toBe(true)
2018-03-12 17:11:05 +00:00
})
})
})