import { describe, expect, it } from "vitest"; import { hasBotCheckMarkers, isScripted, LINK_PREVIEW_USER_AGENTS, REFUSAL_STATUSES, } from "./pageBotChecks"; describe("REFUSAL_STATUSES", () => { it("names the statuses a bot wall answers with", () => { expect([...REFUSAL_STATUSES].sort((a, b) => a - b)).toEqual([ 202, 401, 403, 405, 429, ]); }); it("leaves out the statuses that are not walls", () => { expect(REFUSAL_STATUSES.has(404)).toBe(false); expect(REFUSAL_STATUSES.has(500)).toBe(false); expect(REFUSAL_STATUSES.has(302)).toBe(false); }); }); describe("hasBotCheckMarkers", () => { it("recognizes the Anubis and Akamai challenge pages", () => { expect(hasBotCheckMarkers('
0
')).toBe(true); expect(hasBotCheckMarkers('
')).toBe( true, ); }); it("says no to a page that carries neither marker", () => { expect(hasBotCheckMarkers("

Hello

")).toBe( false, ); }); }); describe("isScripted", () => { it("reads a script tag in any spelling", () => { expect(isScripted("")).toBe(true); expect(isScripted('')).toBe(true); expect(isScripted("")).toBe(true); expect(isScripted("