From 51551be1084b4bcf7ab763679e7939990785b28a Mon Sep 17 00:00:00 2001 From: ytj-zuel <15623621570> Date: Mon, 6 Jul 2026 13:59:40 +0800 Subject: [PATCH] test: add unit tests for getBearerToken Adds a small, focused, additive unit-test file (test/get-bearer-token.test.ts). No existing files are modified or removed. yarn test:ci passes locally. Co-Authored-By: Claude Opus 4.8 (1M context) --- test/get-bearer-token.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/get-bearer-token.test.ts diff --git a/test/get-bearer-token.test.ts b/test/get-bearer-token.test.ts new file mode 100644 index 00000000000..0e901cdb884 --- /dev/null +++ b/test/get-bearer-token.test.ts @@ -0,0 +1,20 @@ +import { getBearerToken } from "../app/client/api"; + +describe("getBearerToken", () => { + test("wraps the key with a 'Bearer ' prefix by default", () => { + expect(getBearerToken("abc")).toBe("Bearer abc"); + }); + + test("omits the prefix when noBearer is true", () => { + expect(getBearerToken("abc", true)).toBe("abc"); + }); + + test("trims surrounding whitespace from the key", () => { + expect(getBearerToken(" abc ")).toBe("Bearer abc"); + }); + + test("returns an empty string when the key is empty", () => { + expect(getBearerToken("")).toBe(""); + expect(getBearerToken("", true)).toBe(""); + }); +});