Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justinshreve committed Nov 26, 2024
1 parent f04498c commit 0555848
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
10 changes: 5 additions & 5 deletions projects/plugins/jetpack/extensions/blocks/gif/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ const TUMBLR_DATA = [
media_key: '9',
media: [ { url: 'pony', poster: { url: 'chips' }, height: 10, width: 10 } ],
attribution: { blog: { name: 'Tumblr Blog' }, url: 'https://tumblr.com' },
embed_url: 'https://embed.tumblr.com/embed/post/1234567890/12345/123123/gif',
},
{
media_key: '99',
media: [ { url: 'horsey', poster: { url: 'fish' }, height: 12, width: 12 } ],
attribution: { blog: { name: 'Another Blog' }, url: 'https://tumblr.com' },
embed_url: 'https://embed.tumblr.com/embed/post/1234567890/12345/123123/gif',
},
];

Expand Down Expand Up @@ -70,7 +72,7 @@ describe( 'GifEdit', () => {
expect( container.querySelector( 'figure' ) ).not.toBeInTheDocument();
} );

test( 'calls API and returns tumblr images', async () => {
test( 'calls API and returns tumblr embed', async () => {
useFetchTumblrData.mockImplementationOnce( () => {
return {
fetchTumblrData,
Expand Down Expand Up @@ -101,18 +103,16 @@ describe( 'GifEdit', () => {
await getUrl( newProps.attributes.searchText )
);
expect( setAttributes.mock.calls[ 0 ][ 0 ] ).toStrictEqual( {
gifUrl: TUMBLR_DATA[ 0 ].media[ 0 ].url,
gifUrl: TUMBLR_DATA[ 0 ].embed_url,
paddingTop: getPaddingTop( TUMBLR_DATA[ 0 ].media[ 0 ] ),
attributionUrl: TUMBLR_DATA[ 0 ].attribution.url,
attributionName: TUMBLR_DATA[ 0 ].attribution.blog.name,
} );

// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
expect( container.querySelector( 'figure' ) ).toBeInTheDocument();
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
expect( container.querySelector( 'figcaption' ) ).toBeInTheDocument();
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
expect( container.querySelector( '.wp-block-jetpack-gif-wrapper img' ) ).toBeInTheDocument();
expect( container.querySelector( '.wp-block-jetpack-gif-wrapper iframe' ) ).toBeInTheDocument();
expect(
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
container.querySelectorAll( '.wp-block-jetpack-gif_thumbnail-container' )
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:jetpack/gif {"caption":"Awww","gifUrl":"https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif","searchText":"cats","paddingTop":"40%","attributionUrl":"https://www.tumblr.com/blog/view/everydayschristmas","attributionName":"everydayschristmas","align":"center","className":"jetpack-test-class"} /-->
<!-- wp:jetpack/gif {"caption":"Awww","gifUrl":"https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif","searchText":"cats","paddingTop":"40%","align":"center","className":"jetpack-test-class"} /-->
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"gifUrl": "https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif",
"searchText": "cats",
"paddingTop": "40%",
"className": "jetpack-test-class",
"attributionName": "everydayschristmas",
"attributionUrl": "https://www.tumblr.com/blog/view/everydayschristmas"
"className": "jetpack-test-class"
},
"innerBlocks": [],
"originalContent": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"gifUrl": "https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif",
"searchText": "cats",
"paddingTop": "40%",
"className": "jetpack-test-class",
"attributionName": "everydayschristmas",
"attributionUrl": "https://www.tumblr.com/blog/view/everydayschristmas"
"className": "jetpack-test-class"
},
"innerBlocks": [],
"innerHTML": "",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!-- wp:jetpack/gif {"caption":"Awww","gifUrl":"https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif","searchText":"cats","paddingTop":"40%","attributionUrl":"https://www.tumblr.com/blog/view/everydayschristmas","attributionName":"everydayschristmas","className":"jetpack-test-class"} /-->
<!-- wp:jetpack/gif {"caption":"Awww","gifUrl":"https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif","searchText":"cats","paddingTop":"40%","className":"jetpack-test-class"} /-->
5 changes: 2 additions & 3 deletions projects/plugins/jetpack/extensions/blocks/gif/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe( 'Gif Block utils', () => {
const TUMBLR_ITEM = {
media: [ { url: 'fuzz', height: 10, width: 10 } ],
attribution: { blog: { name: 'Tumblr Blog' }, url: 'https://tumblr.com' },
embed_url: 'https://embed.tumblr.com/embed/post/1234567890/12345/123123/gif',
};

describe( 'getUrl', () => {
Expand Down Expand Up @@ -36,10 +37,8 @@ describe( 'Gif Block utils', () => {
describe( 'getSelectedGifAttributes', () => {
test( 'returns expected object', () => {
expect( getSelectedGifAttributes( TUMBLR_ITEM ) ).toStrictEqual( {
gifUrl: TUMBLR_ITEM.media[ 0 ].url,
gifUrl: TUMBLR_ITEM.embed_url,
paddingTop: getPaddingTop( TUMBLR_ITEM.media[ 0 ] ),
attributionUrl: TUMBLR_ITEM.attribution.url,
attributionName: TUMBLR_ITEM.attribution.blog.name,
} );
} );
} );
Expand Down

0 comments on commit 0555848

Please sign in to comment.