From 5b2edbbdb7bc7d7c9184dd00d6a47703363848a7 Mon Sep 17 00:00:00 2001 From: Jesse Buchanan Date: Wed, 20 Apr 2016 13:16:17 -0400 Subject: [PATCH] another attempt: got Input DOM, still no event fires :( --- .../higher_order_components/focusable.test.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/higher_order_components/focusable.test.js b/test/higher_order_components/focusable.test.js index 9c062b7..307f6aa 100644 --- a/test/higher_order_components/focusable.test.js +++ b/test/higher_order_components/focusable.test.js @@ -40,8 +40,28 @@ describe('higher order components', () => { }) it('when focusable element is clicked, props.focusable=true', () => { - const wrapper = render() - throw wrapper.find('input') + const wrapper = mount() + 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() + }) })