

























@@ -38,6 +38,14 @@ function responseJson(body: unknown, status = 200): Response {
3838});
3939}
404041+function firstFetchCall(fetchSpy: ReturnType<typeof vi.fn>): [string, RequestInit] {
42+const [call] = fetchSpy.mock.calls;
43+if (!call) {
44+throw new Error("expected fetch call");
45+}
46+return call as [string, RequestInit];
47+}
48+4149describe("generatePkce", () => {
4250it("produces a 64-char hex verifier and a base64url SHA-256 challenge", () => {
4351const { verifier, challenge } = generatePkce();
@@ -191,7 +199,7 @@ describe("exchangeMSTeamsCodeForTokens", () => {
191199192200// Verify the request was well-formed
193201expect(fetchSpy).toHaveBeenCalledOnce();
194-const [url, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
202+const [url, init] = firstFetchCall(fetchSpy);
195203expect(url).toBe(buildMSTeamsTokenEndpoint("tenant-1"));
196204const body = new URLSearchParams(init.body as string);
197205expect(body.get("client_id")).toBe("client-1");
@@ -259,7 +267,7 @@ describe("refreshMSTeamsDelegatedTokens", () => {
259267expect(tokens.expiresAt).toBeGreaterThanOrEqual(now + 3300 * 1000 - 1000);
260268261269// Verify the request body includes refresh_token grant type
262-const [, init] = fetchSpy.mock.calls[0] as [string, RequestInit];
270+const [, init] = firstFetchCall(fetchSpy);
263271const body = new URLSearchParams(init.body as string);
264272expect(body.get("grant_type")).toBe("refresh_token");
265273expect(body.get("refresh_token")).toBe("original-rt");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。