Skip to content

Commit

Permalink
Tests: Mock deprecated when testing if it was called
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Aug 14, 2018
1 parent 3141227 commit cf41540
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/components/src/higher-order/with-context/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import renderer from 'react-test-renderer';
import PropTypes from 'prop-types';

/**
* Internal dependencies
* WordPress dependencies
*/
import withContext from '../';
import { Component } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';

/**
* WordPress dependencies
* Internal dependencies
*/
import { Component } from '@wordpress/element';
import withContext from '../';

jest.mock( '@wordpress/deprecated', () => jest.fn() );

class PassContext extends Component {
getChildContext() {
Expand All @@ -39,7 +42,7 @@ describe( 'withContext', () => {
);

expect( wrapper.root.findByType( 'div' ).children[ 0 ] ).toBe( 'ok' );
expect( console ).toHaveWarned();
expect( deprecated ).toHaveBeenCalled();
} );

it( 'should allow specifying a context getter mapping', () => {
Expand Down

0 comments on commit cf41540

Please sign in to comment.