@@ -104,6 +104,24 @@ describe('oembed-service', function () {
104104 } ) ;
105105 } ) ;
106106
107+ describe ( 'fetchPage' , function ( ) {
108+ it ( 'requests pages with a 5 second timeout' , async function ( ) {
109+ const externalRequest = sinon . stub ( ) . resolves ( { } ) ;
110+
111+ const service = new OembedService ( {
112+ config : { get ( ) {
113+ return true ;
114+ } } ,
115+ externalRequest
116+ } ) ;
117+
118+ await service . fetchPage ( 'https://www.example.com' , { } ) ;
119+
120+ const options = externalRequest . firstCall . args [ 1 ] ;
121+ assert . equal ( options . timeout . request , 5000 ) ;
122+ } ) ;
123+ } ) ;
124+
107125 describe ( 'fetchOembedData' , function ( ) {
108126 const pageHtml = `<html><head><link type="application/json+oembed" href="https://www.example.com/oembed"></head></html>` ;
109127
@@ -182,6 +200,24 @@ describe('oembed-service', function () {
182200 assert . equal ( response . metadata . title , 'Example' ) ;
183201 } ) ;
184202
203+ it ( 'extracts Amazon product metadata via the metascraper-amazon ruleset' , async function ( ) {
204+ nock ( 'https://www.amazon.com' )
205+ . get ( '/dp/B08N5WRWNW' )
206+ . query ( true )
207+ . reply ( 200 , `<html><head><title>Amazon.com</title></head><body>
208+ <span id="productTitle">Example Product Title</span>
209+ <img class="a-dynamic-image" src="https://m.media-amazon.com/images/I/example.jpg" data-old-hires="https://m.media-amazon.com/images/I/example-hires.jpg">
210+ </body></html>` ) ;
211+
212+ const response = await oembedService . fetchOembedDataFromUrl ( 'https://www.amazon.com/dp/B08N5WRWNW' , 'bookmark' ) ;
213+
214+ assert . equal ( response . version , '1.0' ) ;
215+ assert . equal ( response . type , 'bookmark' ) ;
216+ assert . equal ( response . metadata . title , 'Example Product Title' ) ;
217+ assert . equal ( response . metadata . publisher , 'Amazon' ) ;
218+ assert . equal ( response . metadata . thumbnail , 'https://m.media-amazon.com/images/I/example-hires.jpg' ) ;
219+ } ) ;
220+
185221 it ( 'should return a bookmark response when the oembed endpoint returns a link type' , async function ( ) {
186222 nock ( 'https://www.example.com' )
187223 . get ( '/' )
0 commit comments