Test that 'change' event on TaskRow calls onChangeRuleStatus on that rule

pull/3006/head
Jared Scheib 2018-03-21 16:48:57 -07:00
parent 04bfbbfa09
commit 5e7cbede07
2 changed files with 21 additions and 1 deletions

View File

@ -56,7 +56,7 @@ const TasksTable: SFC<TasksTableProps> = ({
)
class TaskRow extends PureComponent<TaskRowProps> {
export class TaskRow extends PureComponent<TaskRowProps> {
handleClickRuleStatusEnabled(task: AlertRule) {
return () => {
this.props.onChangeRuleStatus(task)

View File

@ -2,6 +2,7 @@ import React from 'react'
import {shallow} from 'enzyme'
import TasksTable from 'src/kapacitor/components/TasksTable'
import {TaskRow} from 'src/kapacitor/components/TasksTable'
import {source, kapacitorRules} from 'test/resources'
@ -20,4 +21,23 @@ describe('Kapacitor.Components.TasksTable', () => {
expect(wrapper.exists()).toBe(true)
})
})
describe('user interaction', () => {
const props = {
source,
task: kapacitorRules[3],
onDelete: () => {},
onChangeRuleStatus: jest.fn(),
}
it('calls onChangeRuleStatus when checkbox is effectively clicked', () => {
const wrapper = shallow(<TaskRow {...props} />)
const checkbox = wrapper.find(({type:'checkbox'}))
checkbox.simulate('change')
expect(props.onChangeRuleStatus).toHaveBeenCalledTimes(1)
expect(props.onChangeRuleStatus).toHaveBeenCalledWith(kapacitorRules[3])
})
})
})