test: guard live listing prices

This commit is contained in:
2026-04-30 22:46:48 -04:00
parent 20fb46190a
commit 5c732287c5
2 changed files with 20 additions and 0 deletions

View File

@@ -14,6 +14,16 @@ describe("eBay live parser", () => {
expect(results.length).toBeGreaterThan(0); expect(results.length).toBeGreaterThan(0);
for (const listing of results) { for (const listing of results) {
if (!listing.listingPrice) {
throw new Error(`Expected listing price for ${listing.url}`);
}
if (typeof listing.listingPrice.cents !== "number") {
throw new Error(`Expected listing cents for ${listing.url}`);
}
if (!listing.listingPrice.currency) {
throw new Error(`Expected listing currency for ${listing.url}`);
}
expect(listing.url).toStartWith("https://"); expect(listing.url).toStartWith("https://");
expect(listing.title.length).toBeGreaterThan(0); expect(listing.title.length).toBeGreaterThan(0);
expect(listing.listingPrice.cents).toBeGreaterThanOrEqual(0); expect(listing.listingPrice.cents).toBeGreaterThanOrEqual(0);

View File

@@ -21,6 +21,16 @@ describe("Facebook live parser", () => {
expect(results.length).toBeGreaterThan(0); expect(results.length).toBeGreaterThan(0);
for (const listing of results) { for (const listing of results) {
if (!listing.listingPrice) {
throw new Error(`Expected listing price for ${listing.url}`);
}
if (typeof listing.listingPrice.cents !== "number") {
throw new Error(`Expected listing cents for ${listing.url}`);
}
if (!listing.listingPrice.currency) {
throw new Error(`Expected listing currency for ${listing.url}`);
}
expect(listing.url).toStartWith( expect(listing.url).toStartWith(
"https://www.facebook.com/marketplace/item/", "https://www.facebook.com/marketplace/item/",
); );