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
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>
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
isLinkedInJobUrl,
|
|
isPostingExpiredByDate,
|
|
probeApplicationLink,
|
|
} from "../src/application-link.js";
|
|
|
|
describe("isLinkedInJobUrl", () => {
|
|
it("matches LinkedIn job view URLs", () => {
|
|
expect(
|
|
isLinkedInJobUrl("https://www.linkedin.com/jobs/view/4362000000"),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("rejects non-LinkedIn URLs", () => {
|
|
expect(isLinkedInJobUrl("https://example.com/jobs/1")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("isPostingExpiredByDate", () => {
|
|
it("returns true when expires_at is in the past", () => {
|
|
expect(
|
|
isPostingExpiredByDate(
|
|
"2020-01-01T00:00:00.000Z",
|
|
new Date("2025-01-01"),
|
|
),
|
|
).toBe(true);
|
|
});
|
|
|
|
it("returns false when expires_at is in the future", () => {
|
|
expect(
|
|
isPostingExpiredByDate(
|
|
"2099-01-01T00:00:00.000Z",
|
|
new Date("2025-01-01"),
|
|
),
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("probeApplicationLink", () => {
|
|
it("marks expired when final URL is LinkedIn expired redirect", async () => {
|
|
const fetchImpl = async () =>
|
|
({
|
|
url: "https://www.linkedin.com/jobs/view/expired_jd_redirect/",
|
|
status: 200,
|
|
text: async () => "<html></html>",
|
|
}) as Response;
|
|
|
|
const result = await probeApplicationLink(
|
|
"https://www.linkedin.com/jobs/view/123",
|
|
fetchImpl,
|
|
);
|
|
expect(result?.expired).toBe(true);
|
|
});
|
|
|
|
it("extracts India location from HTML when not expired", async () => {
|
|
const html = `
|
|
<script type="application/ld+json">
|
|
{"@type":"JobPosting","jobLocation":{"address":{"addressLocality":"Bengaluru","addressCountry":"India"}}}
|
|
</script>`;
|
|
const fetchImpl = async () =>
|
|
({
|
|
url: "https://www.linkedin.com/jobs/view/123",
|
|
status: 200,
|
|
text: async () => html,
|
|
}) as Response;
|
|
|
|
const result = await probeApplicationLink(
|
|
"https://www.linkedin.com/jobs/view/123",
|
|
fetchImpl,
|
|
);
|
|
expect(result?.expired).toBe(false);
|
|
expect(result?.location).toMatch(/India/i);
|
|
});
|
|
});
|