Prefer structured Zillow photo data before click path
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import { extractZillowStructuredPhotoCandidatesFromNextDataScript } from "./zillow-photo-data.js";
|
||||
import {
|
||||
extractZillowStructuredPhotoCandidatesFromNextDataScript,
|
||||
shouldUseStructuredZillowPhotos,
|
||||
} from "./zillow-photo-data.js";
|
||||
|
||||
test("extractZillowStructuredPhotoCandidatesFromNextDataScript reads responsivePhotos", () => {
|
||||
const scriptText = JSON.stringify({
|
||||
@@ -67,3 +70,19 @@ test("extractZillowStructuredPhotoCandidatesFromNextDataScript falls back to mix
|
||||
{ url: "https://photos.zillowstatic.com/fp/photo-one-cc_ft_1536.jpg", width: 1536 },
|
||||
]);
|
||||
});
|
||||
|
||||
test("shouldUseStructuredZillowPhotos returns true when structured photos already match the announced count", () => {
|
||||
const candidates = Array.from({ length: 29 }, (_, index) => ({
|
||||
url: `https://photos.zillowstatic.com/fp/photo-${index + 1}-p_d.jpg`,
|
||||
}));
|
||||
|
||||
assert.equal(shouldUseStructuredZillowPhotos(candidates, 29), true);
|
||||
});
|
||||
|
||||
test("shouldUseStructuredZillowPhotos returns false when structured photos are incomplete for the announced count", () => {
|
||||
const candidates = Array.from({ length: 12 }, (_, index) => ({
|
||||
url: `https://photos.zillowstatic.com/fp/photo-${index + 1}-p_d.jpg`,
|
||||
}));
|
||||
|
||||
assert.equal(shouldUseStructuredZillowPhotos(candidates, 29), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user