Skip to content

Commit

Permalink
Reset embed mocks on every request, stop request to instagram (#15046)
Browse files Browse the repository at this point in the history
* Make sure mocks are set up for every embedding test

* Stop request to instagram
  • Loading branch information
notnownikki authored and gziolo committed Apr 18, 2019
1 parent 8a8fe0d commit 58da78c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/e2e-tests/specs/embedding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
clickBlockAppender,
createNewPost,
createEmbeddingMatcher,
createURLMatcher,
setUpResponseMocking,
createJSONResponse,
getEditedPostContent,
Expand Down Expand Up @@ -124,6 +125,12 @@ const MOCK_RESPONSES = [
match: createEmbeddingMatcher( 'https://twitter.com/wooyaygutenberg123454312' ),
onRequestMatch: createJSONResponse( MOCK_CANT_EMBED_RESPONSE ),
},
// Respond to the instagram URL with a non-image response, doesn't matter what it is,
// just make sure the image errors.
{
match: createURLMatcher( 'https://www.instagram.com/p/Bvl97o2AK6x/' ),
onRequestMatch: createJSONResponse( MOCK_CANT_EMBED_RESPONSE ),
},
];

const addAllEmbeds = async () => {
Expand Down Expand Up @@ -178,8 +185,10 @@ const addAllEmbeds = async () => {
};

describe( 'Embedding content', () => {
beforeAll( async () => await setUpResponseMocking( MOCK_RESPONSES ) );
beforeEach( createNewPost );
beforeEach( async () => {
await setUpResponseMocking( MOCK_RESPONSES );
await createNewPost();
} );

it( 'should render embeds in the correct state', async () => {
await addAllEmbeds();
Expand Down

0 comments on commit 58da78c

Please sign in to comment.