From 4394608acf3fee7b62626b19aeba17bd07ffc7b9 Mon Sep 17 00:00:00 2001 From: sealinesun Date: Tue, 8 Oct 2019 14:41:03 -0400 Subject: [PATCH] =?UTF-8?q?Fix(Bs3):=20Remove=20unsafe=20lifecycles=20by?= =?UTF-8?q?=20upgrading=20uncontrollable=E2=80=A6=20(#4597)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix tests broken by using ReactTestUtils on forwardRef components. (See https://github.com/facebook/react/issues/13455) --- package.json | 2 +- src/Dropdown.js | 2 +- src/Navbar.js | 6 +- src/Panel.js | 2 +- src/PanelGroup.js | 2 +- src/TabContainer.js | 2 +- src/Tabs.js | 2 +- src/ToggleButtonGroup.js | 2 +- src/utils/bootstrapUtils.js | 2 +- test/DropdownButtonSpec.js | 37 ++-- test/DropdownSpec.js | 270 +++++++++------------------- test/NavbarSpec.js | 231 ++++++++---------------- test/PanelGroupSpec.js | 14 +- test/PanelSpec.js | 11 +- test/TabsSpec.js | 342 +++++++++++++++++++----------------- yarn.lock | 21 ++- 16 files changed, 382 insertions(+), 566 deletions(-) diff --git a/package.json b/package.json index 625536e6..df79948f 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "react-overlays": "^0.8.0", "react-prop-types": "^0.4.0", "react-transition-group": "^2.0.0", - "uncontrollable": "^5.0.0", + "uncontrollable": "^7.0.2", "warning": "^3.0.0" }, "release-script": { diff --git a/src/Dropdown.js b/src/Dropdown.js index fdca1996..b126f2bc 100644 --- a/src/Dropdown.js +++ b/src/Dropdown.js @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom'; import all from 'prop-types-extra/lib/all'; import elementType from 'prop-types-extra/lib/elementType'; import isRequiredForA11y from 'prop-types-extra/lib/isRequiredForA11y'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import warning from 'warning'; import ButtonGroup from './ButtonGroup'; diff --git a/src/Navbar.js b/src/Navbar.js index 94e9c1b0..3bc5e81f 100644 --- a/src/Navbar.js +++ b/src/Navbar.js @@ -5,7 +5,7 @@ import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import elementType from 'prop-types-extra/lib/elementType'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import Grid from './Grid'; import NavbarBrand from './NavbarBrand'; @@ -259,8 +259,6 @@ UncontrollableNavbar.Text = createSimpleWrapper('p', 'text', 'NavbarText'); UncontrollableNavbar.Link = createSimpleWrapper('a', 'link', 'NavbarLink'); // Set bsStyles here so they can be overridden. -export default bsStyles( - [Style.DEFAULT, Style.INVERSE], - Style.DEFAULT, +export default bsStyles([Style.DEFAULT, Style.INVERSE], Style.DEFAULT)( UncontrollableNavbar ); diff --git a/src/Panel.js b/src/Panel.js index 7a73f506..10f42ba0 100644 --- a/src/Panel.js +++ b/src/Panel.js @@ -1,7 +1,7 @@ import classNames from 'classnames'; import PropTypes from 'prop-types'; import React from 'react'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import warning from 'warning'; import { diff --git a/src/PanelGroup.js b/src/PanelGroup.js index a7fd8466..5cdaf7b7 100644 --- a/src/PanelGroup.js +++ b/src/PanelGroup.js @@ -1,7 +1,7 @@ import classNames from 'classnames'; import PropTypes from 'prop-types'; import React, { cloneElement } from 'react'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import { bsClass, diff --git a/src/TabContainer.js b/src/TabContainer.js index deebb182..af9184ef 100644 --- a/src/TabContainer.js +++ b/src/TabContainer.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; const TAB = 'tab'; const PANE = 'pane'; diff --git a/src/Tabs.js b/src/Tabs.js index d766a4ad..8cba5a3a 100644 --- a/src/Tabs.js +++ b/src/Tabs.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import requiredForA11y from 'prop-types-extra/lib/isRequiredForA11y'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import elementType from 'prop-types-extra/lib/elementType'; import Nav from './Nav'; diff --git a/src/ToggleButtonGroup.js b/src/ToggleButtonGroup.js index 970455c9..a0f0ac93 100644 --- a/src/ToggleButtonGroup.js +++ b/src/ToggleButtonGroup.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import invariant from 'invariant'; -import uncontrollable from 'uncontrollable'; +import { uncontrollable } from 'uncontrollable'; import chainFunction from './utils/createChainedFunction'; import ValidChildren from './utils/ValidComponentChildren'; diff --git a/src/utils/bootstrapUtils.js b/src/utils/bootstrapUtils.js index 5735d17a..491a0e99 100644 --- a/src/utils/bootstrapUtils.js +++ b/src/utils/bootstrapUtils.js @@ -178,7 +178,7 @@ export function splitBsPropsAndOmit(props, omittedPropNames) { * in order to validate the new variant. */ export function addStyle(Component, ...styleVariant) { - bsStyles(styleVariant, Component); + bsStyles(styleVariant)(Component); } export const _curry = curry; diff --git a/test/DropdownButtonSpec.js b/test/DropdownButtonSpec.js index 66e0eab3..ef9b7f15 100644 --- a/test/DropdownButtonSpec.js +++ b/test/DropdownButtonSpec.js @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import ReactTestUtils from 'react-dom/test-utils'; +import { mount } from 'enzyme'; import Dropdown from '../src/Dropdown'; import DropdownButton from '../src/DropdownButton'; @@ -224,30 +225,24 @@ describe('', () => { }); it('should pass defaultOpen to ``', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( MenuItem 1 content ); - const dropdown = ReactTestUtils.findRenderedComponentWithType( - instance, - Dropdown - ); - const toggle = ReactTestUtils.findRenderedComponentWithType( - instance, - DropdownToggle - ); + const dropdown = wrapper.find(Dropdown).first(); + const toggle = wrapper.find(DropdownToggle).first(); - expect(dropdown.props.defaultOpen).to.equal(true); - expect(toggle.props.defaultOpen).to.not.exist; + expect(dropdown.props().defaultOpen).to.equal(true); + expect(toggle.props().defaultOpen).to.not.exist; }); it('should pass onMouseEnter and onMouseLeave to ``', () => { const onMouseEnter = () => {}; const onMouseLeave = () => {}; - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( ', () => { ); - const dropdown = ReactTestUtils.findRenderedComponentWithType( - instance, - Dropdown - ); - const toggle = ReactTestUtils.findRenderedComponentWithType( - instance, - DropdownToggle - ); + const dropdown = wrapper.find(Dropdown).first(); + const toggle = wrapper.find(DropdownToggle).first(); - expect(dropdown.props.onMouseEnter).to.equal(onMouseEnter); - expect(dropdown.props.onMouseLeave).to.equal(onMouseLeave); + expect(dropdown.props().onMouseEnter).to.equal(onMouseEnter); + expect(dropdown.props().onMouseLeave).to.equal(onMouseLeave); - expect(toggle.props.onMouseEnter).to.not.exist; - expect(toggle.props.onMouseLeave).to.not.exist; + expect(toggle.props().onMouseEnter).to.not.exist; + expect(toggle.props().onMouseLeave).to.not.exist; }); }); diff --git a/test/DropdownSpec.js b/test/DropdownSpec.js index b097a265..46119dbd 100644 --- a/test/DropdownSpec.js +++ b/test/DropdownSpec.js @@ -33,8 +33,8 @@ describe('', () => { const simpleDropdown = {dropdownChildren}; it('renders div with dropdown class', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); node.tagName.should.equal('DIV'); node.className.should.match(/\bdropdown\b/); @@ -42,12 +42,12 @@ describe('', () => { }); it('renders div with dropup class', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const node = ReactDOM.findDOMNode(instance); + const node = wrapper.getDOMNode(); node.tagName.should.equal('DIV'); node.className.should.not.match(/\bdropdown\b/); @@ -55,12 +55,8 @@ describe('', () => { }); it('renders toggle with Dropdown.Toggle', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const buttonNode = wrapper.find('button').getDOMNode(); buttonNode.textContent.should.match(/Child Title/); @@ -74,11 +70,8 @@ describe('', () => { }); it('renders dropdown toggle button caret', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const caretNode = ReactTestUtils.findRenderedDOMComponentWithClass( - instance, - 'caret' - ); + const wrapper = mount(simpleDropdown); + const caretNode = wrapper.find('.caret').getDOMNode(); caretNode.tagName.should.equal('SPAN'); }); @@ -96,7 +89,7 @@ describe('', () => { }); it('renders custom menu', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( Child Text @@ -106,14 +99,8 @@ describe('', () => { ); - ReactTestUtils.scryRenderedComponentsWithType( - instance, - DropdownMenu - ).length.should.equal(0); - ReactTestUtils.scryRenderedComponentsWithType( - instance, - CustomMenu - ).length.should.equal(1); + expect(wrapper.find(DropdownMenu)).to.have.lengthOf(0); + expect(wrapper.find(CustomMenu)).to.have.lengthOf(1); }); it('prop validation with multiple menus', () => { @@ -139,29 +126,23 @@ describe('', () => { }); it('forwards pullRight to menu', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const menu = ReactTestUtils.findRenderedComponentWithType( - instance, - DropdownMenu - ); + const menu = wrapper.find(DropdownMenu); - menu.props.pullRight.should.be.true; + expect(menu.props().pullRight).to.be.true; }); // NOTE: The onClick event handler is invoked for both the Enter and Space // keys as well since the component is a button. I cannot figure out how to // get ReactTestUtils to simulate such though. it('toggles open/closed when clicked', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); node.className.should.not.match(/\bopen\b/); buttonNode.getAttribute('aria-expanded').should.equal('false'); @@ -178,12 +159,9 @@ describe('', () => { }); it('closes when clicked outside', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); node.className.should.not.match(/\bopen\b/); buttonNode.getAttribute('aria-expanded').should.equal('false'); @@ -202,16 +180,13 @@ describe('', () => { }); it('closes when mousedown outside if rootCloseEvent set', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); node.className.should.not.match(/\bopen\b/); buttonNode.getAttribute('aria-expanded').should.equal('false'); @@ -230,7 +205,7 @@ describe('', () => { }); it('opens if dropdown contains no focusable menu item', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( Toggle @@ -238,22 +213,16 @@ describe('', () => { ); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); ReactTestUtils.Simulate.click(buttonNode); node.className.should.match(/\bopen\b/); }); it('when focused and closed toggles open when the key "down" is pressed', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); ReactTestUtils.Simulate.keyDown(buttonNode, { keyCode: keycode('down') }); @@ -262,11 +231,8 @@ describe('', () => { }); it('button has aria-haspopup attribute (As per W3C WAI-ARIA Spec)', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const buttonNode = wrapper.find('button').getDOMNode(); buttonNode.getAttribute('aria-haspopup').should.equal('true'); }); @@ -279,21 +245,17 @@ describe('', () => { }); it('closes when child MenuItem is selected', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); - const node = ReactDOM.findDOMNode(instance); - - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const buttonNode = wrapper.find('button').getDOMNode(); ReactTestUtils.Simulate.click(buttonNode); node.className.should.match(/\bopen\b/); - const menuItem = ReactTestUtils.scryRenderedDOMComponentsWithTag( - instance, - 'A' - )[0]; + const menuItem = wrapper + .find('a') + .first() + .getDOMNode(); ReactTestUtils.Simulate.click(menuItem); node.className.should.not.match(/\bopen\b/); }); @@ -301,22 +263,17 @@ describe('', () => { it('does not close when onToggle is controlled', () => { const handleSelect = () => {}; - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); - - const menuItem = ReactTestUtils.scryRenderedDOMComponentsWithTag( - instance, - 'A' - )[0]; + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); + const menuItem = wrapper + .find('a') + .first() + .getDOMNode(); ReactTestUtils.Simulate.click(buttonNode); node.className.should.match(/\bopen\b/); @@ -375,12 +332,9 @@ describe('', () => { }); it('has aria-labelledby same id as toggle button', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); const menuNode = node.children[1]; buttonNode @@ -444,10 +398,7 @@ describe('', () => { class RefDropdown extends React.Component { render() { return ( - (this.dropdown = dropdown.inner)} - id="test" - > + (this.dropdown = dropdown)} id="test"> (this.toggle = toggle)} /> (this.menu = menu)} /> @@ -495,31 +446,22 @@ describe('', () => { }); it('when focused and closed sets focus on first menu item when the key "down" is pressed', () => { - const instance = ReactDOM.render(simpleDropdown, focusableContainer); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); - + const wrapper = mount(simpleDropdown, { attachTo: focusableContainer }); + const buttonNode = wrapper.find('button').getDOMNode(); buttonNode.focus(); - ReactTestUtils.Simulate.keyDown(buttonNode, { keyCode: keycode('down') }); - const firstMenuItemAnchor = ReactTestUtils.scryRenderedDOMComponentsWithTag( - instance, - 'A' - )[0]; - + const firstMenuItemAnchor = wrapper + .find('a') + .first() + .getDOMNode(); document.activeElement.should.equal(firstMenuItemAnchor); }); it('when focused and open does not toggle closed when the key "down" is pressed', () => { - const instance = ReactTestUtils.renderIntoDocument(simpleDropdown); - const node = ReactDOM.findDOMNode(instance); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const wrapper = mount(simpleDropdown); + const node = wrapper.getDOMNode(); + const buttonNode = wrapper.find('button').getDOMNode(); ReactTestUtils.Simulate.click(buttonNode); ReactTestUtils.Simulate.keyDown(buttonNode, { keyCode: keycode('down') }); @@ -530,25 +472,22 @@ describe('', () => { // This test is more complicated then it appears to need. This is // because there was an intermittent failure of the test when not structured this way - // The failure occured when all tests in the suite were run together, but not a subset of the tests. + // The failure occurred when all tests in the suite were run together, but not a subset of the tests. // // I am fairly confident that the failure is due to a test specific conflict and not an actual bug. it('when open and the key "esc" is pressed the menu is closed and focus is returned to the button', () => { - const instance = ReactDOM.render( + const wrapper = mount( {dropdownChildren} , - focusableContainer + { attachTo: focusableContainer } ); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); - const firstMenuItemAnchor = ReactTestUtils.scryRenderedDOMComponentsWithTag( - instance, - 'A' - )[0]; + const buttonNode = wrapper.find('button').getDOMNode(); + const firstMenuItemAnchor = wrapper + .find('a') + .first() + .getDOMNode(); document.activeElement.should.equal(firstMenuItemAnchor); @@ -561,25 +500,15 @@ describe('', () => { }); it('when open and the key "tab" is pressed the menu is closed and focus is progress to the next focusable element', done => { - const instance = ReactDOM.render( + const wrapper = mount( {simpleDropdown} , - focusableContainer - ); - - // Need to use Grid instead of div above to make instance a composite - // element, to make this call legal. - const node = ReactTestUtils.findRenderedComponentWithType( - instance, - Dropdown - ); - - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - node, - 'BUTTON' + { attachTo: focusableContainer } ); + const node = wrapper.find(Dropdown); + const buttonNode = node.find('button').getDOMNode(); ReactTestUtils.Simulate.click(buttonNode); buttonNode.getAttribute('aria-expanded').should.equal('true'); @@ -615,15 +544,12 @@ describe('', () => { it('passes open, event, and source correctly when opened with click', () => { const spy = sinon.spy(); - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const buttonNode = wrapper.find('button').getDOMNode(); expect(spy).to.not.have.been.called; @@ -638,15 +564,12 @@ describe('', () => { it('passes open, event, and source correctly when closed with click', () => { const spy = sinon.spy(); - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const buttonNode = wrapper.find('button').getDOMNode(); expect(spy).to.not.have.been.called; ReactTestUtils.Simulate.click(buttonNode); @@ -662,7 +585,7 @@ describe('', () => { it('passes open, event, and source correctly when child selected', () => { const spy = sinon.spy(); - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( Child Title @@ -670,14 +593,8 @@ describe('', () => { ); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); - const childNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'A' - ); + const buttonNode = wrapper.find('button').getDOMNode(); + const childNode = wrapper.find('a').getDOMNode(); expect(spy).to.not.have.been.called; ReactTestUtils.Simulate.click(buttonNode); @@ -694,15 +611,12 @@ describe('', () => { it('passes open, event, and source correctly when opened with keydown', () => { const spy = sinon.spy(); - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( {dropdownChildren} ); - const buttonNode = ReactTestUtils.findRenderedDOMComponentWithTag( - instance, - 'BUTTON' - ); + const buttonNode = wrapper.find('button').getDOMNode(); ReactTestUtils.Simulate.keyDown(buttonNode, { key: 'Down Arrow', @@ -719,7 +633,7 @@ describe('', () => { }); it('should derive bsClass from parent', () => { - const instance = ReactTestUtils.renderIntoDocument( + const wrapper = mount( Child Title @@ -728,26 +642,10 @@ describe('', () => { ); - assert.ok( - ReactTestUtils.findRenderedDOMComponentWithClass( - instance, - 'my-dropdown-toggle' - ) - ); - assert.ok( - ReactTestUtils.findRenderedDOMComponentWithClass( - instance, - 'my-dropdown-menu' - ) - ); + expect(wrapper.exists('.my-dropdown-toggle')).to.be.true; + expect(wrapper.exists('.my-dropdown-menu')).to.be.true; - assert.lengthOf( - ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'my-toggle'), - 0 - ); - assert.lengthOf( - ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'my-menu'), - 0 - ); + expect(wrapper.find('.my-toggle')).to.have.lengthOf(0); + expect(wrapper.find('.my-menu')).to.have.lengthOf(0); }); }); diff --git a/test/NavbarSpec.js b/test/NavbarSpec.js index e604c5d3..9f216b20 100644 --- a/test/NavbarSpec.js +++ b/test/NavbarSpec.js @@ -1,6 +1,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import ReactTestUtils from 'react-dom/test-utils'; +import { mount } from 'enzyme'; import Nav from '../src/Nav'; import Navbar from '../src/Navbar'; @@ -12,103 +13,65 @@ import { getOne } from './helpers'; describe('', () => { it('Should create nav element', () => { - const instance = ReactTestUtils.renderIntoDocument(); - const nav = ReactDOM.findDOMNode(instance); + const wrapper = mount(); + const nav = wrapper.getDOMNode(); assert.equal(nav.nodeName, 'NAV'); assert.ok(nav.className.match(/\bnavbar\b/)); assert.notOk(nav.getAttribute('role')); }); it('Should add "navigation" role when not using a `