test(facebook): add live parser suite
This commit is contained in:
34
packages/core/test/live/facebook.live.test.ts
Normal file
34
packages/core/test/live/facebook.live.test.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import fetchFacebookItems from "../../src/scrapers/facebook";
|
||||
|
||||
const LIVE_RESULT_LIMIT = 3;
|
||||
const LIVE_TEST_TIMEOUT_MS = 30_000;
|
||||
|
||||
describe("Facebook live parser", () => {
|
||||
test(
|
||||
"scrapes live marketplace search results into listing details",
|
||||
async () => {
|
||||
if (!process.env.FACEBOOK_COOKIE?.trim()) {
|
||||
throw new Error("FACEBOOK_COOKIE is required for Facebook live tests");
|
||||
}
|
||||
|
||||
const results = await fetchFacebookItems(
|
||||
"iphone",
|
||||
1,
|
||||
"toronto",
|
||||
LIVE_RESULT_LIMIT,
|
||||
);
|
||||
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
for (const listing of results) {
|
||||
expect(listing.url).toStartWith(
|
||||
"https://www.facebook.com/marketplace/item/",
|
||||
);
|
||||
expect(listing.title.length).toBeGreaterThan(0);
|
||||
expect(listing.listingPrice.cents).toBeGreaterThanOrEqual(0);
|
||||
expect(listing.listingPrice.currency.length).toBeGreaterThan(0);
|
||||
}
|
||||
},
|
||||
LIVE_TEST_TIMEOUT_MS,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user