Skip to content

Commit 979974d

Browse files
committed
test: add tests
1 parent 958f4ed commit 979974d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/sessionManager/stores/localStorage.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, it, expect, beforeEach, vi } from "vitest";
22
import { LocalStorage } from "./localStorage";
33
import { StorageKeys } from "../types";
4+
import { storageSettings } from "..";
45

56
enum ExtraKeys {
67
testKey = "testKey2",
@@ -33,6 +34,22 @@ describe("LocalStorage standard keys", () => {
3334
sessionManager = new LocalStorage();
3435
});
3536

37+
it("should show warning when using local storage access token explicity", async () => {
38+
storageSettings.useInsecureForRefreshToken = true;
39+
const consoleSpy = vi.spyOn(console, "warn");
40+
new LocalStorage();
41+
expect(consoleSpy).toHaveBeenCalledWith(
42+
"LocalStorage store should not be used in production",
43+
);
44+
storageSettings.useInsecureForRefreshToken = false;
45+
});
46+
47+
it("should not show warning when using secure refresh tokens", async () => {
48+
const consoleSpy = vi.spyOn(console, "warn");
49+
new LocalStorage();
50+
expect(consoleSpy).not.toHaveBeenCalled();
51+
});
52+
3653
it("should set and get an item in session storage", async () => {
3754
await sessionManager.setSessionItem(StorageKeys.accessToken, "testValue");
3855
expect(await sessionManager.getSessionItem(StorageKeys.accessToken)).toBe(

0 commit comments

Comments
 (0)