Skip to content

Commit

Permalink
another attempt: got Input DOM, still no event fires :(
Browse files Browse the repository at this point in the history
  • Loading branch information
jbinto authored and SpiritBreaker226 committed Apr 20, 2016
1 parent 3df6cc7 commit 5b2edbb
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/higher_order_components/focusable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,28 @@ describe('higher order components', () => {
})

it('when focusable element is clicked, props.focusable=true', () => {
const wrapper = render(<Layout />)
throw wrapper.find('input')
const wrapper = mount(<Layout />)
const example = wrapper.find(ExampleFocusable)
expect(example.prop('focused')).not.to.exist()

const reactElement = wrapper.get(0)
const domNode = ReactDOM.findDOMNode(reactElement)

// Finally figured out how to get the HTMLInputElement!
const input = domNode.querySelectorAll('input')[0]

// Nice try, but no cigar.
input.click()

// Here is some frail attempt to force React to re-render.
wrapper.setState({ 'bogus': 'rerender' })

// It doesn't matter.
// The _onDocumentClick event on focusable never fires.
// Thought now is to use window.dispatchEvent to handle this.

expect(example.prop('focused')).to.be.true()

})

})

0 comments on commit 5b2edbb

Please sign in to comment.