Skip to content

Commit b6877c0

Browse files
committed
test: minor updates
1 parent 00a554f commit b6877c0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/utils/exchangeAuthCode.test.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { describe, expect, it, vi, beforeEach, afterEach } from "vitest";
22
import { exchangeAuthCode } from ".";
33
import { MemoryStorage, StorageKeys } from "../sessionManager";
4-
import { setActiveStorage } from "./token";
4+
import { getActiveStorage, setActiveStorage } from "./token";
55
import createFetchMock from "vitest-fetch-mock";
66
import { frameworkSettings } from "./exchangeAuthCode";
77

88
const fetchMock = createFetchMock(vi);
99

10-
describe("exhangeAuthCode", () => {
10+
describe("exchangeAuthCode", () => {
1111
beforeEach(() => {
1212
fetchMock.enableMocks();
1313
});
@@ -56,13 +56,16 @@ describe("exhangeAuthCode", () => {
5656
urlParams.append("code", "test");
5757

5858
expect(
59-
exchangeAuthCode({
59+
await exchangeAuthCode({
6060
urlParams,
6161
domain: "http://test.kinde.com",
6262
clientId: "test",
63-
redirectURL: "http://test.kinde.com",
63+
redirectURL: "http://test.kinde.coma",
6464
}),
65-
).rejects.toThrowError("No active storage found");
65+
).toStrictEqual({
66+
error: "Authentication storage is not initialized",
67+
success: false,
68+
});
6669
});
6770

6871
it("state mismatch", async () => {
@@ -192,7 +195,7 @@ describe("exhangeAuthCode", () => {
192195
});
193196
});
194197

195-
it("set the framework and version on header", async () => {
198+
it("should handle token exchange failure", async () => {
196199
const store = new MemoryStorage();
197200
setActiveStorage(store);
198201

@@ -202,9 +205,6 @@ describe("exhangeAuthCode", () => {
202205
[StorageKeys.state]: state,
203206
});
204207

205-
frameworkSettings.framework = "Framework";
206-
frameworkSettings.frameworkVersion = "Version";
207-
208208
const input = "hello";
209209

210210
const urlParams = new URLSearchParams();

0 commit comments

Comments
 (0)