Skip to content

Commit

Permalink
Fix a few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla committed Aug 31, 2022
1 parent 1906e24 commit b1161cd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/block-library/src/block/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ describe( 'Reusable block', () => {
response = [ reusableBlockMock1, reusableBlockMock2 ];
} else if ( path.startsWith( '/wp/v2/blocks/1' ) ) {
response = reusableBlockMock1;
} else if (
path.startsWith( '/wp/v2/block-patterns/categories' )
) {
response = [];
}
return Promise.resolve( response );
} );
Expand Down
17 changes: 17 additions & 0 deletions packages/block-library/src/embed/test/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ const mockEmbedResponses = ( mockedResponses ) => {
] );
}

if ( path.startsWith( '/wp/v2/block-patterns/categories' ) ) {
return Promise.resolve( [] );
}

const matchedEmbedResponse = mockedResponses.find(
( mockedResponse ) =>
path ===
Expand Down Expand Up @@ -698,6 +702,9 @@ describe( 'Embed block', () => {
response = RICH_TEXT_EMBED_SUCCESS_RESPONSE;
}
}
if ( path.startsWith( '/wp/v2/block-patterns/categories' ) ) {
response = [];
}
return Promise.resolve( response );
} );

Expand All @@ -724,6 +731,9 @@ describe( 'Embed block', () => {
it( 'converts to link if preview request failed', async () => {
// Return bad response for requests to oembed endpoint.
fetchRequest.mockImplementation( ( { path } ) => {
if ( path.startsWith( '/wp/v2/block-patterns/categories' ) ) {
return Promise.resolve( [] );
}
const isEmbedRequest = path.startsWith( '/oembed/1.0/proxy' );
return Promise.resolve(
isEmbedRequest ? MOCK_BAD_WORDPRESS_RESPONSE : {}
Expand Down Expand Up @@ -761,6 +771,10 @@ describe( 'Embed block', () => {
response = MOCK_BAD_WORDPRESS_RESPONSE;
} else if ( matchesPath( successURL ) ) {
response = RICH_TEXT_EMBED_SUCCESS_RESPONSE;
} else if (
path.startsWith( '/wp/v2/block-patterns/categories' )
) {
response = [];
}

return Promise.resolve( response );
Expand Down Expand Up @@ -1048,6 +1062,9 @@ describe( 'Embed block', () => {
it( 'displays cannot embed on the placeholder if preview data is null', async () => {
// Return null response for requests to oembed endpoint.
fetchRequest.mockImplementation( ( { path } ) => {
if ( path.startsWith( '/wp/v2/block-patterns/categories' ) ) {
return Promise.resolve( [] );
}
const isEmbedRequest = path.startsWith( '/oembed/1.0/proxy' );
return Promise.resolve( isEmbedRequest ? EMBED_NULL_RESPONSE : {} );
} );
Expand Down

0 comments on commit b1161cd

Please sign in to comment.