Add failing test for KapacitorRules renders both tables with unique checkbox IDs

pull/10616/head
Jared Scheib 2018-03-16 15:58:06 -07:00
parent 9cfac3450c
commit eeda415eb7
1 changed files with 28 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import React from 'react'
import {shallow} from 'enzyme'
import _ from 'lodash'
import KapacitorRules from 'src/kapacitor/components/KapacitorRules'
import {source, kapacitorRules} from 'test/resources'
@ -12,14 +14,14 @@ const setup = () => {
hasKapacitor: true,
loading: false,
onDelete: () => {},
onChangeRuleStatus: () => {}
onChangeRuleStatus: () => {},
}
const wrapper = shallow(<KapacitorRules {...props} />)
return {
wrapper,
props
props,
}
}
@ -46,5 +48,29 @@ describe('Kapacitor.Containers.KapacitorRules', () => {
const tasksTable = wrapper.find('TasksTable')
expect(tasksTable.length).toEqual(1)
})
it('renders each rule/task checkboxes with unique "id" attribute', () => {
const {wrapper} = setup()
const kapacitorRulesTableRowsIDs = wrapper
.find('KapacitorRulesTable')
.dive()
.find('tbody')
.children()
.map(child => child.dive().find({type: 'checkbox'}).props().id)
const tasksTableIDs = wrapper
.find('TasksTable')
.dive()
.find('tbody')
.children()
.map(child => child.dive().find({type: 'checkbox'}).props().id)
const allCheckboxesIDs = kapacitorRulesTableRowsIDs.concat(tasksTableIDs)
const containsAnyDuplicate = arr => _.uniq(arr).length !== arr.length
expect(containsAnyDuplicate(allCheckboxesIDs)).toEqual(false)
})
})
})