Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed May 25, 2019
1 parent 5565d5c commit 71984ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/data/src/components/with-dispatch/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TestRenderer from 'react-test-renderer';
*/
import withDispatch from '../';
import { createRegistry } from '../../../registry';
import RegistryProvider from '../../registry-provider';
import { RegistryProvider } from '../../registry-provider';

describe( 'withDispatch', () => {
let registry;
Expand Down
18 changes: 13 additions & 5 deletions packages/viewport/src/test/if-viewport-matches.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* External dependencies
*/
import TestRenderer from 'react-test-renderer';
import TestRenderer, { act } from 'react-test-renderer';

/**
* WordPress dependencies
Expand All @@ -20,16 +20,24 @@ describe( 'ifViewportMatches()', () => {
it( 'should not render if query does not match', () => {
dispatch( 'core/viewport' ).setIsMatching( { '> wide': false } );
const EnhancedComponent = ifViewportMatches( '> wide' )( Component );
const testRenderer = TestRenderer.create( <EnhancedComponent /> );

let testRenderer;
act( () => {
testRenderer = TestRenderer.create( <EnhancedComponent /> );
} );

expect( testRenderer.root.findAllByType( Component ) ).toHaveLength( 0 );
} );

it( 'should render if query does match', () => {
dispatch( 'core/viewport' ).setIsMatching( { '> wide': true } );
act( () => {
dispatch( 'core/viewport' ).setIsMatching( { '> wide': true } );
} );
const EnhancedComponent = ifViewportMatches( '> wide' )( Component );
const testRenderer = TestRenderer.create( <EnhancedComponent /> );

let testRenderer;
act( () => {
testRenderer = TestRenderer.create( <EnhancedComponent /> );
} );
expect( testRenderer.root.findAllByType( Component ) ).toHaveLength( 1 );
} );
} );

0 comments on commit 71984ee

Please sign in to comment.