test: guard live listing prices
This commit is contained in:
@@ -14,6 +14,16 @@ describe("eBay live parser", () => {
|
||||
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
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.title.length).toBeGreaterThan(0);
|
||||
expect(listing.listingPrice.cents).toBeGreaterThanOrEqual(0);
|
||||
|
||||
@@ -21,6 +21,16 @@ describe("Facebook live parser", () => {
|
||||
|
||||
expect(results.length).toBeGreaterThan(0);
|
||||
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://www.facebook.com/marketplace/item/",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user