placeholder
); const tree = TestUtils.renderIntoDocument( elem ); - assert( ! tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( false ); TestUtils.Simulate.click( ReactDom.findDOMNode( TestUtils.findRenderedDOMComponentWithClass( tree, 'section-nav__mobile-header' ) ) ); - assert( tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( true ); } ); } ); test( 'should call onMobileNavPanelOpen function passed as a prop twice when tapped three times', () => { return new Promise( ( done ) => { - const spy = sinon.spy(); + const spy = jest.fn(); const elem = createElement( SectionNav, { @@ -123,27 +121,27 @@ describe( 'section-nav', () => { ); const tree = TestUtils.renderIntoDocument( elem ); - assert( ! tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( false ); TestUtils.Simulate.click( ReactDom.findDOMNode( TestUtils.findRenderedDOMComponentWithClass( tree, 'section-nav__mobile-header' ) ) ); - assert( tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( true ); TestUtils.Simulate.click( ReactDom.findDOMNode( TestUtils.findRenderedDOMComponentWithClass( tree, 'section-nav__mobile-header' ) ) ); - assert( ! tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( false ); TestUtils.Simulate.click( ReactDom.findDOMNode( TestUtils.findRenderedDOMComponentWithClass( tree, 'section-nav__mobile-header' ) ) ); - assert( tree.state.mobileOpen ); + expect( tree.state.mobileOpen ).toBe( true ); - assert( spy.calledTwice ); + expect( spy ).toHaveBeenCalledTimes( 2 ); done(); } ); } ); diff --git a/client/components/select-dropdown/test/index.js b/client/components/select-dropdown/test/index.js index 91bef82b8b5a6..a9122bddfba43 100644 --- a/client/components/select-dropdown/test/index.js +++ b/client/components/select-dropdown/test/index.js @@ -1,10 +1,7 @@ /** * @jest-environment jsdom */ - -import { expect } from 'chai'; import { shallow, mount } from 'enzyme'; -import sinon from 'sinon'; import SelectDropdown from '../index'; describe( 'index', () => { @@ -13,43 +10,43 @@ describe( 'index', () => { const dropdown = mountDropdown(); expect( dropdown.find( '.select-dropdown__options li.select-dropdown__label' ).text() - ).to.eql( 'Statuses' ); + ).toEqual( 'Statuses' ); expect( dropdown.find( '.select-dropdown__options li.select-dropdown__option' ) - ).to.have.lengthOf( 4 ); + ).toHaveLength( 4 ); } ); test( 'should render a separator in place of any falsy option', () => { const dropdown = mountDropdown(); expect( dropdown.find( '.select-dropdown__options li.select-dropdown__separator' ) - ).to.have.lengthOf( 1 ); + ).toHaveLength( 1 ); } ); test( 'should be initially closed', () => { const dropdown = shallowRenderDropdown(); - expect( dropdown.find( '.select-dropdown' ) ).to.have.lengthOf( 1 ); - expect( dropdown.find( '.select-dropdown.is-open' ) ).to.be.empty; + expect( dropdown.find( '.select-dropdown' ) ).toHaveLength( 1 ); + expect( dropdown.find( '.select-dropdown.is-open' ) ).toHaveLength( 0 ); } ); test( 'should execute toggleDropdown when clicked', () => { const dropdown = shallowRenderDropdown(); dropdown.find( '.select-dropdown__container' ).simulate( 'click' ); - expect( dropdown.find( '.select-dropdown.is-open' ) ).to.have.lengthOf( 1 ); + expect( dropdown.find( '.select-dropdown.is-open' ) ).toHaveLength( 1 ); } ); test( 'should not respond when clicked when disabled', () => { const dropdown = shallowRenderDropdown( { disabled: true } ); - expect( dropdown.find( '.select-dropdown.is-disabled' ) ).to.have.lengthOf( 1 ); + expect( dropdown.find( '.select-dropdown.is-disabled' ) ).toHaveLength( 1 ); dropdown.find( '.select-dropdown__container' ).simulate( 'click' ); - expect( dropdown.find( '.select-dropdown.is-open' ) ).to.be.empty; + expect( dropdown.find( '.select-dropdown.is-open' ) ).toHaveLength( 0 ); // Repeat to be sure dropdown.find( '.select-dropdown__container' ).simulate( 'click' ); - expect( dropdown.find( '.select-dropdown.is-open' ) ).to.be.empty; + expect( dropdown.find( '.select-dropdown.is-open' ) ).toHaveLength( 0 ); } ); test( 'should be possible to open the dropdown via keyboard', () => { @@ -57,7 +54,7 @@ describe( 'index', () => { // simulate pressing 'space' key dropdown.find( '.select-dropdown__container' ).simulate( 'keydown', createKeyEvent( 32 ) ); - expect( dropdown.find( '.select-dropdown.is-open' ) ).to.have.lengthOf( 1 ); + expect( dropdown.find( '.select-dropdown.is-open' ) ).toHaveLength( 1 ); } ); } ); @@ -65,18 +62,18 @@ describe( 'index', () => { test( 'should return the initially selected value (if any)', () => { const dropdown = shallowRenderDropdown( { initialSelected: 'drafts' } ); const initialSelectedValue = dropdown.instance().getInitialSelectedItem(); - expect( initialSelectedValue ).to.equal( 'drafts' ); + expect( initialSelectedValue ).toEqual( 'drafts' ); } ); test( "should return `undefined`, when there aren't options", () => { const dropdown = shallow(