Files
Gregory Schier b4a1c418bb Run oxfmt across repo, add format script and docs
Add .oxfmtignore to skip generated bindings and wasm-pack output.
Add npm format script, update DEVELOPMENT.md for Vite+ toolchain,
and format all non-generated files with oxfmt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 10:15:49 -07:00

68 lines
1.9 KiB
TypeScript

import type { Context } from "@yaakapp/api";
import { describe, expect, test } from "vite-plus/test";
import { plugin } from "../src";
const ctx = {} as Context;
describe("auth-bearer", () => {
test("No values", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: {},
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "" }] });
});
test("Only token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { token: "my-token" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "my-token" }] });
});
test("Only prefix", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "Hello" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello" }] });
});
test("Prefix and token", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "Hello", token: "my-token" },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
test("Extra spaces", async () => {
expect(
await plugin.authentication?.onApply(ctx, {
values: { prefix: "\t Hello ", token: " \nmy-token " },
headers: [],
url: "https://yaak.app",
method: "POST",
contextId: "111",
}),
).toEqual({ setHeaders: [{ name: "Authorization", value: "Hello my-token" }] });
});
});