Skip to content

Commit

Permalink
update scrapeConfig tests and remove default format api param
Browse files Browse the repository at this point in the history
mazen-r committed May 22, 2024
1 parent 08cede5 commit dd709bb
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions __tests__/scrapeconfig.test.ts
Original file line number Diff line number Diff line change
@@ -194,6 +194,21 @@ describe('url param generation', () => {
'screenshots[everything]': 'fullpage',
});
});
it('screenshot flags converted to params', () => {
const config = new ScrapeConfig({
url: 'http://httpbin.dev/get',
screenshots: { everything: 'fullpage' },
screenshot_flags: "load_images,dark_mode,block_banners,high_quality,print_media_format",
render_js: true,
});
expect(config.toApiParams({ key: '1234' })).toEqual({
key: '1234',
url: 'http://httpbin.dev/get',
'screenshots[everything]': 'fullpage',
screenshot_flags: "load_images,dark_mode,block_banners,high_quality,print_media_format",
render_js: true,
});
});
it('asp enables', () => {
const config = new ScrapeConfig({
url: 'http://httpbin.dev/get',
@@ -238,6 +253,17 @@ describe('url param generation', () => {
tags: 'foo,bar,gaz',
});
});
it('format set', () => {
const config = new ScrapeConfig({
url: 'http://httpbin.dev/get',
format: "markdown",
});
expect(config.toApiParams({ key: '1234' })).toEqual({
key: '1234',
url: 'http://httpbin.dev/get',
format: "markdown",
});
});
it('debug sets', () => {
const config = new ScrapeConfig({
url: 'http://httpbin.dev/get',
4 changes: 2 additions & 2 deletions src/scrapeconfig.ts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ export class ScrapeConfig {
proxy_pool?: string = null;
session?: string = null;
tags: Set<string> = new Set<string>();
format?: 'json' | 'text' | 'markdown' | 'clean_html' | 'raw' = 'raw'; //unchanged
format?: string = null; // raw(unchanged)
correlation_id?: string = null;
cookies?: Rec<string> = null;
body?: string = null;
@@ -62,7 +62,7 @@ export class ScrapeConfig {
proxy_pool?: string;
session?: string;
tags?: Array<string>;
format?: 'json' | 'text' | 'markdown' | 'clean_html' | 'raw';
format?: string;
correlation_id?: string;
cookies?: Rec<string>;
body?: string;

0 comments on commit dd709bb

Please sign in to comment.