release: WRNexusJS 0.8.0
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { captchaFields, captchaHeaders, captchaTokenFrom } from "../src/index.ts";
|
||||
|
||||
describe("CAPTCHA helper kit", () => {
|
||||
test("reads standard response tokens from forms, headers, and objects", async () => {
|
||||
const form = new FormData();
|
||||
form.set("wrn-captcha-response", "form-token");
|
||||
expect(await captchaTokenFrom(form)).toBe("form-token");
|
||||
expect(await captchaTokenFrom(new Headers({ "x-wrn-captcha-token": "header-token" }))).toBe(
|
||||
"header-token",
|
||||
);
|
||||
expect(await captchaTokenFrom({ "wrn-captcha-response": "object-token" })).toBe("object-token");
|
||||
});
|
||||
|
||||
test("creates consistent fields and headers", () => {
|
||||
expect(captchaFields("token")).toEqual({ "wrn-captcha-response": "token" });
|
||||
expect(new Headers(captchaHeaders("token")).get("x-wrn-captcha-token")).toBe("token");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user