Skip to content

Commit 19ccb41

Browse files
committed
test: fix tests
1 parent b4fde7a commit 19ccb41

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/utils/token/getDecodedToken.test.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { setActiveStorage } from ".";
55
import { createMockAccessToken } from "./testUtils";
66

77
describe("getDecodedToken", () => {
8-
it("error when no active storage is set", () => {
9-
expect(() => getDecodedToken("idToken")).rejects.toThrowError(
10-
"Session manager is not initialized",
11-
);
8+
it("return null when no active storage is defined", async () => {
9+
expect(await getDecodedToken("idToken")).toBe(null);
1210
});
1311
});
1412

lib/utils/token/getDecodedToken.ts

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ export const getDecodedToken = async <
1616
): Promise<T | null> => {
1717
const activeStorage = getActiveStorage();
1818

19+
if (!activeStorage) {
20+
return null;
21+
}
22+
1923
const token = (await activeStorage.getSessionItem(
2024
tokenType === "accessToken" ? StorageKeys.accessToken : StorageKeys.idToken,
2125
)) as string;

0 commit comments

Comments
 (0)