@@ -3,6 +3,7 @@ import { HttpMethod } from '../../src/types.ts';
33import { ScrapeConfigError } from '../../src/errors.ts' ;
44import { assertEquals , assertThrows } from "https://deno.land/std@0.224.0/assert/mod.ts" ;
55
6+ const input_content_type = 'text/html' ;
67
78Deno . test ( 'scrapeconfig loads' , ( ) => {
89 const config = new ScrapeConfig ( { url : 'http://httpbin.dev/get' } ) ;
@@ -15,8 +16,6 @@ Deno.test('scrapeconfig throws on unknown options', () => {
1516 } , ScrapeConfigError , "Invalid option provided: foobar" ) ;
1617} ) ;
1718
18-
19-
2019Deno . test ( 'scrapeconfig allowed methods' , ( ) => {
2120 ( [ 'GET' , 'POST' , 'PUT' , 'PATCH' , 'HEAD' ] as HttpMethod [ ] ) . forEach ( ( method ) => {
2221 const config = new ScrapeConfig ( {
@@ -360,6 +359,58 @@ Deno.test('url param generation: proxy_pool sets', () => {
360359 } ) ;
361360} ) ;
362361
362+ Deno . test ( 'url param generation: sets extraction_template' , async ( ) => {
363+ const config = new ScrapeConfig ( {
364+ url : 'http://httpbin.dev/get' ,
365+ extraction_template : 'my_template' ,
366+ } ) ;
367+ const params = config . toApiParams ( { key : '1234' } ) ;
368+ assertEquals ( params , {
369+ key : '1234' ,
370+ url : 'http://httpbin.dev/get' ,
371+ extraction_template : 'my_template' ,
372+ } ) ;
373+ } ) ;
374+
375+ Deno . test ( 'url param generation: sets extraction_ephemeral_template' , async ( ) => {
376+ const config = new ScrapeConfig ( {
377+ url : 'http://httpbin.dev/get' ,
378+ extraction_ephemeral_template : { source : 'html' , selectors : [ ] } ,
379+ } ) ;
380+ const params = config . toApiParams ( { key : '1234' } ) ;
381+ assertEquals ( params , {
382+ key : '1234' ,
383+ url : 'http://httpbin.dev/get' ,
384+ extraction_template : 'ephemeral:eyJzb3VyY2UiOiJodG1sIiwic2VsZWN0b3JzIjpbXX0' ,
385+ } ) ;
386+ } ) ;
387+
388+ Deno . test ( 'url param generation: sets extraction_prompt' , async ( ) => {
389+ const config = new ScrapeConfig ( {
390+ url : 'http://httpbin.dev/get' ,
391+ extraction_prompt : 'summarize the document' ,
392+ } ) ;
393+ const params = config . toApiParams ( { key : '1234' } ) ;
394+ assertEquals ( params , {
395+ key : '1234' ,
396+ url : 'http://httpbin.dev/get' ,
397+ extraction_prompt : 'summarize the document' ,
398+ } ) ;
399+ } ) ;
400+
401+ Deno . test ( 'url param generation: sets extraction_model' , async ( ) => {
402+ const config = new ScrapeConfig ( {
403+ url : 'http://httpbin.dev/get' ,
404+ extraction_model : 'review_list' ,
405+ } ) ;
406+ const params = config . toApiParams ( { key : '1234' } ) ;
407+ assertEquals ( params , {
408+ key : '1234' ,
409+ url : 'http://httpbin.dev/get' ,
410+ extraction_model : 'review_list' ,
411+ } ) ;
412+ } ) ;
413+
363414Deno . test ( 'url param generation: session sets' , ( ) => {
364415 const config = new ScrapeConfig ( {
365416 url : 'http://httpbin.dev/get' ,
0 commit comments