import test from "node:test"; import assert from "node:assert/strict"; import { resolvePublicRecords } from "../src/public-records.js"; const geocoderPayload = { result: { addressMatches: [ { matchedAddress: "4141 WHITELEY DR, CORPUS CHRISTI, TX, 78418", coordinates: { x: -97.30174, y: 27.613668 }, geographies: { States: [{ NAME: "Texas", STUSAB: "TX", STATE: "48" }], Counties: [{ NAME: "Nueces County", COUNTY: "355", GEOID: "48355" }], "2020 Census Blocks": [{ GEOID: "483550031013005" }] } } ] } }; const countyIndexHtml = ` `; const countyPageHtml = `

Appraisal District

Last Updated: 08/13/2025

Chief Appraiser: Debra Morin, Interim

Phone: 361-881-9978
Email: info@nuecescad.net
Website: www.ncadistrict.com

Mailing Address

201 N. Chaparral St.
Corpus Christi, TX 78401-2503

Tax Assessor/Collector

Last Updated: 02/18/2025

Tax Assessor-Collector: Kevin Kieschnick

Phone: 361-888-0307
Email: nueces.tax@nuecesco.com
Website: www.nuecesco.com

Street Address

901 Leopard St., Room 301
Corpus Christi, Texas 78401-3602

`; const fakeFetchText = async (url: string): Promise => { if (url.includes("geocoding.geo.census.gov")) { return JSON.stringify(geocoderPayload); } if (url.endsWith("/county-directory/")) { return countyIndexHtml; } if (url.endsWith("/county-directory/nueces.php")) { return countyPageHtml; } throw new Error(`Unexpected URL: ${url}`); }; test("resolvePublicRecords uses Census and Texas county directory", async () => { const payload = await resolvePublicRecords("4141 Whiteley Dr, Corpus Christi, TX 78418", { parcelId: "14069438", listingGeoId: "233290", listingSourceUrl: "https://www.zillow.com/homedetails/example", fetchText: fakeFetchText }); assert.equal(payload.county.name, "Nueces County"); assert.equal(payload.state.code, "TX"); assert.equal(payload.appraisalDistrict?.Website, "http://www.ncadistrict.com/"); assert.equal(payload.taxAssessorCollector?.Email, "nueces.tax@nuecesco.com"); assert.equal(payload.sourceIdentifierHints.parcelId, "14069438"); assert.match(payload.lookupRecommendations.join(" "), /listing geo IDs as regional hints only/i); });