Skip to content

Commit dd709bb

Browse files
committed
update scrapeConfig tests and remove default format api param
1 parent 08cede5 commit dd709bb

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

__tests__/scrapeconfig.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,21 @@ describe('url param generation', () => {
194194
'screenshots[everything]': 'fullpage',
195195
});
196196
});
197+
it('screenshot flags converted to params', () => {
198+
const config = new ScrapeConfig({
199+
url: 'http://httpbin.dev/get',
200+
screenshots: { everything: 'fullpage' },
201+
screenshot_flags: "load_images,dark_mode,block_banners,high_quality,print_media_format",
202+
render_js: true,
203+
});
204+
expect(config.toApiParams({ key: '1234' })).toEqual({
205+
key: '1234',
206+
url: 'http://httpbin.dev/get',
207+
'screenshots[everything]': 'fullpage',
208+
screenshot_flags: "load_images,dark_mode,block_banners,high_quality,print_media_format",
209+
render_js: true,
210+
});
211+
});
197212
it('asp enables', () => {
198213
const config = new ScrapeConfig({
199214
url: 'http://httpbin.dev/get',
@@ -238,6 +253,17 @@ describe('url param generation', () => {
238253
tags: 'foo,bar,gaz',
239254
});
240255
});
256+
it('format set', () => {
257+
const config = new ScrapeConfig({
258+
url: 'http://httpbin.dev/get',
259+
format: "markdown",
260+
});
261+
expect(config.toApiParams({ key: '1234' })).toEqual({
262+
key: '1234',
263+
url: 'http://httpbin.dev/get',
264+
format: "markdown",
265+
});
266+
});
241267
it('debug sets', () => {
242268
const config = new ScrapeConfig({
243269
url: 'http://httpbin.dev/get',

src/scrapeconfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ScrapeConfig {
2424
proxy_pool?: string = null;
2525
session?: string = null;
2626
tags: Set<string> = new Set<string>();
27-
format?: 'json' | 'text' | 'markdown' | 'clean_html' | 'raw' = 'raw'; //unchanged
27+
format?: string = null; // raw(unchanged)
2828
correlation_id?: string = null;
2929
cookies?: Rec<string> = null;
3030
body?: string = null;
@@ -62,7 +62,7 @@ export class ScrapeConfig {
6262
proxy_pool?: string;
6363
session?: string;
6464
tags?: Array<string>;
65-
format?: 'json' | 'text' | 'markdown' | 'clean_html' | 'raw';
65+
format?: string;
6666
correlation_id?: string;
6767
cookies?: Rec<string>;
6868
body?: string;

0 commit comments

Comments
 (0)