Skip to content

Commit f76f144

Browse files
Jeniterclaude
andauthored
test: add unit tests for getBearerToken (#6843)
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: ytj-zuel <15623621570> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f4c706a commit f76f144

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/get-bearer-token.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { getBearerToken } from "../app/client/api";
2+
3+
describe("getBearerToken", () => {
4+
test("wraps the key with a 'Bearer ' prefix by default", () => {
5+
expect(getBearerToken("abc")).toBe("Bearer abc");
6+
});
7+
8+
test("omits the prefix when noBearer is true", () => {
9+
expect(getBearerToken("abc", true)).toBe("abc");
10+
});
11+
12+
test("trims surrounding whitespace from the key", () => {
13+
expect(getBearerToken(" abc ")).toBe("Bearer abc");
14+
});
15+
16+
test("returns an empty string when the key is empty", () => {
17+
expect(getBearerToken("")).toBe("");
18+
expect(getBearerToken("", true)).toBe("");
19+
});
20+
});

0 commit comments

Comments
 (0)