Skip to content

Commit cf41540

Browse files
committed
Tests: Mock deprecated when testing if it was called
1 parent 3141227 commit cf41540

File tree

1 file changed

+8
-5
lines changed
  • packages/components/src/higher-order/with-context/test

1 file changed

+8
-5
lines changed

packages/components/src/higher-order/with-context/test/index.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import renderer from 'react-test-renderer';
55
import PropTypes from 'prop-types';
66

77
/**
8-
* Internal dependencies
8+
* WordPress dependencies
99
*/
10-
import withContext from '../';
10+
import { Component } from '@wordpress/element';
11+
import deprecated from '@wordpress/deprecated';
1112

1213
/**
13-
* WordPress dependencies
14+
* Internal dependencies
1415
*/
15-
import { Component } from '@wordpress/element';
16+
import withContext from '../';
17+
18+
jest.mock( '@wordpress/deprecated', () => jest.fn() );
1619

1720
class PassContext extends Component {
1821
getChildContext() {
@@ -39,7 +42,7 @@ describe( 'withContext', () => {
3942
);
4043

4144
expect( wrapper.root.findByType( 'div' ).children[ 0 ] ).toBe( 'ok' );
42-
expect( console ).toHaveWarned();
45+
expect( deprecated ).toHaveBeenCalled();
4346
} );
4447

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

0 commit comments

Comments
 (0)