Jobber/extractors/qajobsboard/tests/detail-page.test.ts
ilia d28a6221e4
Some checks failed
CI / Linting (Biome) (push) Failing after 41s
CI / Tests (push) Successful in 6m10s
CI / Type Check (adzuna-extractor) (push) Successful in 1m9s
CI / Type Check (gradcracker-extractor) (push) Successful in 1m13s
CI / Type Check (hiringcafe-extractor) (push) Successful in 1m9s
CI / Type Check (orchestrator) (push) Failing after 1m16s
CI / Type Check (startupjobs-extractor) (push) Successful in 1m9s
CI / Type Check (ukvisajobs-extractor) (push) Successful in 1m10s
CI / Documentation (push) Successful in 1m56s
fix(qajobsboard): drop expired LinkedIn reposts and resolve hiring location
Probe application links for closed listings and feed expires_at; enrich vague Remote/Worldwide rows with real country before blocked-countries filtering.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-16 17:42:19 -04:00

41 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
extractJobLocationFromText,
parseQaJobDetailPage,
} from "../src/detail-page.js";
const SAMPLE_JSON_LD = `<!DOCTYPE html><html><body>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "JobPosting",
"title": "Sr. QA Automation Engineer",
"description": "<p><strong>Job Location: Mumbai/Nagpur</strong></p><p>India | UK | USA</p>",
"jobLocationType": "TELECOMMUTE"
}
</script>
</body></html>`;
describe("parseQaJobDetailPage", () => {
it("extracts job location from JSON-LD description on the detail page", () => {
const result = parseQaJobDetailPage(SAMPLE_JSON_LD);
expect(result?.location).toBe("Mumbai/Nagpur");
expect(result?.jobDescription).toContain("Mumbai/Nagpur");
});
it("marks posting expired when validThrough is in the past", () => {
const html = `<script type="application/ld+json">
{"@type":"JobPosting","validThrough":"2020-01-01","title":"Old role"}
</script>`;
expect(parseQaJobDetailPage(html)).toEqual({ expired: true });
});
it("extracts job location lines from plain text", () => {
expect(
extractJobLocationFromText(
"Job Location: Vancouver, British Columbia, Canada",
),
).toBe("Vancouver, British Columbia, Canada");
});
});