refactor: share scraper http fetching
This commit is contained in:
@@ -38,4 +38,23 @@ describe("fetchHtml", () => {
|
||||
|
||||
expect(scheduledDelays).not.toContain(1000);
|
||||
});
|
||||
|
||||
test("fetchHtml returns responseUrl when includeResponseUrl is true", async () => {
|
||||
process.env.NODE_ENV = "test";
|
||||
global.fetch = mock(() =>
|
||||
Promise.resolve({
|
||||
ok: true,
|
||||
status: 200,
|
||||
url: "https://example.test/final",
|
||||
headers: { get: () => null },
|
||||
text: () => Promise.resolve("<html></html>"),
|
||||
}),
|
||||
) as unknown as typeof fetch;
|
||||
|
||||
const result = await fetchHtml("https://example.test", 0, {
|
||||
includeResponseUrl: true,
|
||||
});
|
||||
expect(result.html).toBe("<html></html>");
|
||||
expect(result.responseUrl).toBe("https://example.test/final");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user