33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { discoverListingSources } from "../src/listing-discovery.js";
|
|
import { extractPhotoData } from "../src/photo-review.js";
|
|
|
|
test("discoverListingSources times out stalled Zillow and HAR discovery calls", async () => {
|
|
const result = await discoverListingSources(
|
|
"1011 Ennis Joslin Rd APT 235, Corpus Christi, TX 78412",
|
|
{
|
|
timeoutMs: 20,
|
|
discoverZillowListingFn: async () => await new Promise(() => {}),
|
|
discoverHarListingFn: async () => await new Promise(() => {})
|
|
}
|
|
);
|
|
|
|
assert.equal(result.zillowUrl, null);
|
|
assert.equal(result.harUrl, null);
|
|
assert.match(result.attempts.join(" "), /zillow discovery timed out/i);
|
|
assert.match(result.attempts.join(" "), /har discovery timed out/i);
|
|
});
|
|
|
|
test("extractPhotoData times out a stalled photo extraction instead of hanging forever", async () => {
|
|
await assert.rejects(
|
|
async () =>
|
|
extractPhotoData("zillow", "https://www.zillow.com/example", {
|
|
timeoutMs: 20,
|
|
extractZillowPhotosFn: async () => await new Promise(() => {})
|
|
}),
|
|
/timed out/i
|
|
);
|
|
});
|