Test that 'change' event on RuleRow calls onChangeRuleStatus on that rule
parent
82910d0a19
commit
dd46e6e43d
|
@ -5,7 +5,6 @@ import _ from 'lodash'
|
|||
|
||||
import KapacitorRules from 'src/kapacitor/components/KapacitorRules'
|
||||
import KapacitorRulesTable from 'src/kapacitor/components/KapacitorRulesTable'
|
||||
import {RuleRow} from 'src/kapacitor/components/KapacitorRulesTable'
|
||||
import TasksTable from 'src/kapacitor/components/TasksTable'
|
||||
|
||||
import {source, kapacitorRules} from 'test/resources'
|
||||
|
@ -151,20 +150,3 @@ describe('Kapacitor.Containers.KapacitorRules', () => {
|
|||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Kapacitor.Containers.KapacitorRules.RuleRow', () => {
|
||||
const props = {
|
||||
source,
|
||||
rule: kapacitorRules[0],
|
||||
onDelete: () => {},
|
||||
onChangeRuleStatus: () => {},
|
||||
}
|
||||
|
||||
describe('rendering', () => {
|
||||
it('renders RuleRow', () => {
|
||||
const wrapper = shallow(<RuleRow {...props} />)
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -2,30 +2,56 @@ import React from 'react'
|
|||
import {shallow} from 'enzyme'
|
||||
|
||||
import KapacitorRulesTable from 'src/kapacitor/components/KapacitorRulesTable'
|
||||
import {RuleRow} from 'src/kapacitor/components/KapacitorRulesTable'
|
||||
|
||||
import {source, kapacitorRules} from 'test/resources'
|
||||
|
||||
const setup = () => {
|
||||
const props = {
|
||||
source,
|
||||
rules: kapacitorRules,
|
||||
onDelete: () => {},
|
||||
onChangeRuleStatus: () => {}
|
||||
}
|
||||
|
||||
const wrapper = shallow(<KapacitorRulesTable {...props} />)
|
||||
|
||||
return {
|
||||
wrapper,
|
||||
props
|
||||
}
|
||||
}
|
||||
|
||||
describe('Kapacitor.Components.KapacitorRulesTable', () => {
|
||||
describe('rendering', () => {
|
||||
const props = {
|
||||
source,
|
||||
rules: kapacitorRules,
|
||||
onDelete: () => {},
|
||||
onChangeRuleStatus: () => {}
|
||||
}
|
||||
|
||||
it('renders KapacitorRulesTable', () => {
|
||||
const {wrapper} = setup()
|
||||
const wrapper = shallow(<KapacitorRulesTable {...props} />)
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Kapacitor.Containers.KapacitorRulesTable.RuleRow', () => {
|
||||
const props = {
|
||||
source,
|
||||
rule: kapacitorRules[0],
|
||||
onDelete: () => {},
|
||||
onChangeRuleStatus: jest.fn(),
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('rendering', () => {
|
||||
it('renders RuleRow', () => {
|
||||
const wrapper = shallow(<RuleRow {...props} />)
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('user interaction', () => {
|
||||
it('calls onChangeRuleStatus when checkbox is effectively clicked', () => {
|
||||
const wrapper = shallow(<RuleRow {...props} />)
|
||||
|
||||
const checkbox = wrapper.find({type:'checkbox'})
|
||||
checkbox.simulate('change')
|
||||
|
||||
expect(props.onChangeRuleStatus).toHaveBeenCalledTimes(1)
|
||||
expect(props.onChangeRuleStatus).toHaveBeenCalledWith(kapacitorRules[0])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue