Add basic test around threshold
parent
8659693490
commit
f526f6dba0
|
@ -1,4 +1,4 @@
|
|||
import React, {PureComponent, ChangeEvent} from 'react'
|
||||
import React, {PureComponent, ChangeEvent, KeyboardEvent} from 'react'
|
||||
|
||||
import ColorDropdown from 'src/shared/components/ColorDropdown'
|
||||
import {THRESHOLD_COLORS} from 'src/shared/constants/thresholds'
|
||||
|
@ -7,7 +7,7 @@ interface SelectedColor {
|
|||
hex: string
|
||||
name: string
|
||||
}
|
||||
interface Threshold {
|
||||
interface ThresholdProps {
|
||||
type: string
|
||||
hex: string
|
||||
id: string
|
||||
|
@ -17,12 +17,15 @@ interface Threshold {
|
|||
|
||||
interface Props {
|
||||
visualizationType: string
|
||||
threshold: Threshold
|
||||
threshold: ThresholdProps
|
||||
disableMaxColor: boolean
|
||||
onChooseColor: (threshold: Threshold) => void
|
||||
onValidateColorValue: (threshold: Threshold, targetValue: number) => boolean
|
||||
onUpdateColorValue: (threshold: Threshold, targetValue: number) => void
|
||||
onDeleteThreshold: (threshold: Threshold) => void
|
||||
onChooseColor: (threshold: ThresholdProps) => void
|
||||
onValidateColorValue: (
|
||||
threshold: ThresholdProps,
|
||||
targetValue: number
|
||||
) => boolean
|
||||
onUpdateColorValue: (threshold: ThresholdProps, targetValue: number) => void
|
||||
onDeleteThreshold: (threshold: ThresholdProps) => void
|
||||
isMin: boolean
|
||||
isMax: boolean
|
||||
}
|
||||
|
@ -154,7 +157,7 @@ class Threshold extends PureComponent<Props, State> {
|
|||
}
|
||||
}
|
||||
|
||||
private handleKeyUp = (e: KeyboardEvent) => {
|
||||
private handleKeyUp = (e: KeyboardEvent<HTMLInputElement>) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.thresholdInputRef.blur()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import ThresholdProps from 'src/dashboards/components/Threshold'
|
||||
|
||||
import React from 'react'
|
||||
import {shallow} from 'enzyme'
|
||||
|
||||
describe('Threshold', () => {
|
||||
it('renders without an error', () => {
|
||||
const props = {
|
||||
visualizationType: 'gauge',
|
||||
threshold: {
|
||||
type: 'color',
|
||||
hex: '#444444',
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
value: 2,
|
||||
},
|
||||
disableMaxColor: true,
|
||||
onChooseColor: () => {},
|
||||
onValidateColorValue: () => true,
|
||||
onUpdateColorValue: () => {},
|
||||
onDeleteThreshold: () => {},
|
||||
isMin: false,
|
||||
isMax: true,
|
||||
}
|
||||
|
||||
const wrapper = shallow(<ThresholdProps {...props} />)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue