Test that 'change' event on TaskRow calls onChangeRuleStatus on that rule
parent
04bfbbfa09
commit
5e7cbede07
|
@ -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)
|
||||
|
|
|
@ -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])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue