Skip to content

Commit

Permalink
RNMobile: Add integration test to verify button block border radius f…
Browse files Browse the repository at this point in the history
…unctionality (#33211)

* Add setup for button radius test

* Tweak query in test

* Clean up bottons tests

* Clean up buttons test further

* RNMobile: Fix reusable block test assertion

The test should assert the existance of a React element but because of a missing `await`, was instead asserting an unresolved Promise instead. Since the unresolved Promise is a value, `toBeDefined` was returning `true` and the test was passing.
Fixing the test involves resolving the Promise using `await` so that what's asserted is an actual React element.

* Update useResizeObserver mock

Co-authored-by: Carlos Garcia <fluiddot@gmail.com>
  • Loading branch information
2 people authored and enejb committed Jul 17, 2021
1 parent 7ee5882 commit edcc76a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/block-library/src/block/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ describe( 'Reusable block', () => {
},
} );

const headingInnerBlock = waitFor( () =>
const headingInnerBlock = await waitFor( () =>
within( reusableBlock ).getByA11yLabel(
'Heading Block. Row 1. Level 2. First Reusable block'
)
Expand Down
11 changes: 11 additions & 0 deletions test/native/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,14 @@ jest.mock( 'react-native/Libraries/Components/Switch/Switch', () => {
'react-native/Libraries/Components/Switch/Switch'
);
} );

jest.mock( '@wordpress/compose', () => {
return {
...jest.requireActual( '@wordpress/compose' ),
useViewportMatch: jest.fn(),
useResizeObserver: jest.fn( () => [
mockComponent( 'ResizeObserverMock' )( {} ),
{ width: 100, height: 100 },
] ),
};
} );

0 comments on commit edcc76a

Please sign in to comment.