Skip to content

Commit

Permalink
Fix fetchLinkSuggestions unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petitphp committed Feb 3, 2024
1 parent 933d757 commit 5f64b37
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jest.mock( '@wordpress/api-fetch', () =>
url: 'http://wordpress.local/contact-page/',
type: 'post',
subtype: 'page',
label: 'Page',
},
] );
case '/wp/v2/search?search=&per_page=20&type=term':
Expand All @@ -25,12 +26,14 @@ jest.mock( '@wordpress/api-fetch', () =>
title: 'Cats',
url: 'http://wordpress.local/category/cats/',
type: 'category',
label: 'Category',
},
{
id: 1,
title: 'Uncategorized',
url: 'http://wordpress.local/category/uncategorized/',
type: 'category',
label: 'Category',
},
] );
case '/wp/v2/search?search=&per_page=20&type=post-format':
Expand All @@ -41,13 +44,15 @@ jest.mock( '@wordpress/api-fetch', () =>
url: 'http://wordpress.local/type/gallery/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
{
id: 'quote',
title: 'Quote',
url: 'http://wordpress.local/type/quote/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
] );
case '/wp/v2/search?search=&per_page=3&type=post&subtype=page':
Expand All @@ -58,6 +63,7 @@ jest.mock( '@wordpress/api-fetch', () =>
url: 'http://wordpress.local/limit-case/',
type: 'post',
subtype: 'page',
label: 'Page',
},
] );
case '/wp/v2/search?search=&page=11&per_page=20&type=post&subtype=page':
Expand All @@ -68,9 +74,10 @@ jest.mock( '@wordpress/api-fetch', () =>
url: 'http://wordpress.local/page-case/',
type: 'post',
subtype: 'page',
label: 'Page',
},
] );
case '/wp/v2/media?search=&per_page=20':
case '/wp/v2/search?search=&per_page=20&type=media':
return Promise.resolve( [
{
id: 54,
Expand All @@ -80,6 +87,7 @@ jest.mock( '@wordpress/api-fetch', () =>
type: 'attachment',
source_url:
'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
label: 'Attachment',
},
] );
default:
Expand Down Expand Up @@ -108,6 +116,7 @@ describe( 'fetchLinkSuggestions', () => {
type: 'page',
url: 'http://wordpress.local/contact-page/',
kind: 'post-type',
label: 'Page',
},
] )
);
Expand All @@ -124,13 +133,15 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/category/cats/',
type: 'category',
kind: 'taxonomy',
label: 'Category',
},
{
id: 1,
title: 'Uncategorized',
url: 'http://wordpress.local/category/uncategorized/',
type: 'category',
kind: 'taxonomy',
label: 'Category',
},
] )
);
Expand All @@ -146,13 +157,15 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/type/gallery/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
{
id: 'quote',
title: 'Quote',
url: 'http://wordpress.local/type/quote/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
] )
);
Expand All @@ -178,6 +191,7 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
type: 'attachment',
kind: 'media',
label: 'Attachment',
},
] )
);
Expand All @@ -192,41 +206,47 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/contact-page/',
type: 'page',
kind: 'post-type',
label: 'Page',
},
{
id: 9,
title: 'Cats',
url: 'http://wordpress.local/category/cats/',
type: 'category',
kind: 'taxonomy',
label: 'Category',
},
{
id: 1,
title: 'Uncategorized',
url: 'http://wordpress.local/category/uncategorized/',
type: 'category',
kind: 'taxonomy',
label: 'Category',
},
{
id: 'gallery',
title: 'Gallery',
url: 'http://wordpress.local/type/gallery/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
{
id: 'quote',
title: 'Quote',
url: 'http://wordpress.local/type/quote/',
type: 'post-format',
kind: 'taxonomy',
label: 'post-format',
},
{
id: 54,
title: 'Some Test Media Title',
url: 'http://localhost:8888/wp-content/uploads/2022/03/test-pdf.pdf',
type: 'attachment',
kind: 'media',
label: 'Attachment',
},
] )
);
Expand All @@ -245,6 +265,7 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/limit-case/',
type: 'page',
kind: 'post-type',
label: 'Page',
},
] )
);
Expand All @@ -270,6 +291,7 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/page-case/',
type: 'page',
kind: 'post-type',
label: 'Page',
},
] )
);
Expand All @@ -294,6 +316,7 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/page-case/',
type: 'page',
kind: 'post-type',
label: 'Page',
},
] )
);
Expand All @@ -312,6 +335,7 @@ describe( 'fetchLinkSuggestions', () => {
url: 'http://wordpress.local/page-case/',
type: 'page',
kind: 'post-type',
label: 'Page',
},
] )
);
Expand Down

0 comments on commit 5f64b37

Please sign in to comment.