WIP fix tests

pull/3142/head
Alex P 2018-04-05 18:02:43 -07:00
parent 73f9c15eea
commit 66a838a9dd
1 changed files with 30 additions and 9 deletions

View File

@ -1,7 +1,7 @@
import React from 'react' import React from 'react'
import {shallow} from 'enzyme' import {shallow} from 'enzyme'
import {FuncSelector} from 'src/ifql/components/FuncSelector' import {FuncSelector} from 'src/ifql/components/FuncSelector'
import DropdownInput from 'src/shared/components/DropdownInput' import FuncSelectorInput from 'src/shared/components/FuncSelectorInput'
import FuncListItem from 'src/ifql/components/FuncListItem' import FuncListItem from 'src/ifql/components/FuncListItem'
import FuncList from 'src/ifql/components/FuncList' import FuncList from 'src/ifql/components/FuncList'
@ -82,7 +82,7 @@ describe('IFQL.Components.FuncsButton', () => {
const input = wrapper const input = wrapper
.find(FuncList) .find(FuncList)
.dive() .dive()
.find(DropdownInput) .find(FuncSelectorInput)
.dive() .dive()
.find('input') .find('input')
@ -94,10 +94,10 @@ describe('IFQL.Components.FuncsButton', () => {
.dive() .dive()
.find(FuncListItem) .find(FuncListItem)
const func = list.first().dive() const func = list.first()
expect(list.length).toBe(1) expect(list.length).toBe(1)
expect(func.text()).toBe('f2') expect(func.dive().text()).toBe('f2')
}) })
}) })
@ -118,20 +118,41 @@ describe('IFQL.Components.FuncsButton', () => {
const input = wrapper const input = wrapper
.find(FuncList) .find(FuncList)
.dive() .dive()
.find(DropdownInput) .find(FuncSelectorInput)
.dive() .dive()
.find('input') .find('input')
input.simulate('keyDown', {key: 'Escape'}) input.simulate('keyDown', {key: 'Escape'})
wrapper.update() wrapper.update()
list = wrapper list = wrapper.find(FuncList)
.find(FuncList)
.dive()
.find(FuncListItem)
expect(list.exists()).toBe(false) expect(list.exists()).toBe(false)
}) })
}) })
describe('selecting a function with the keyboard', () => {
describe('ArrowDown', () => {
it('adds a function to the page', () => {
const onAddNode = jest.fn()
const {wrapper} = setup({onAddNode})
const dropdownButton = wrapper.find('button')
dropdownButton.simulate('click')
const list = wrapper.find(FuncList).dive()
const input = list
.find(FuncSelectorInput)
.dive()
.find('input')
input.simulate('keyDown', {key: 'ArrowDown'})
input.simulate('keyDown', {key: 'Enter'})
expect(onAddNode).toHaveBeenCalledWith('f2')
})
})
})
}) })
}) })