import { describe, expect, it } from "bun:test"; import { buildBackendContextHeaders } from "../../src/auth/backendContextHeaders.js"; describe("buildBackendContextHeaders", () => { it("forwards authenticated project and trace context to the backend", () => { expect( buildBackendContextHeaders({ accessToken: "access-token-1", projectId: "project-id-1", traceId: "trace-id-1", }), ).toEqual({ Accept: "application/json", "Content-Type": "application/json", Authorization: "Bearer access-token-1", "X-Project-Id": "project-id-1", "X-Trace-Id": "trace-id-1", }); }); it("omits optional authentication and project headers when unavailable", () => { expect(buildBackendContextHeaders({ traceId: "trace-id-2" })).toEqual({ Accept: "application/json", "Content-Type": "application/json", "X-Trace-Id": "trace-id-2", }); }); });