Skip to content

Commit 5eef173

Browse files
committed
fix(test): removes conditional localStorage mock, always uses vi.fn()
1 parent a7a783b commit 5eef173

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

tests/components/onboarding/OnboardingWizard.test.tsx

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,16 @@ describe("OnboardingWizard", () => {
6868
writable: true,
6969
value: { replace: vi.fn(), href: "" },
7070
});
71-
if (
72-
typeof localStorage === "undefined" ||
73-
typeof localStorage.setItem !== "function"
74-
) {
75-
Object.defineProperty(window, "localStorage", {
76-
configurable: true,
77-
writable: true,
78-
value: {
79-
setItem: vi.fn(),
80-
getItem: vi.fn(() => null),
81-
removeItem: vi.fn(),
82-
clear: vi.fn(),
83-
},
84-
});
85-
} else {
86-
vi.spyOn(localStorage, "setItem").mockImplementation(() => {});
87-
}
71+
Object.defineProperty(window, "localStorage", {
72+
configurable: true,
73+
writable: true,
74+
value: {
75+
setItem: vi.fn(),
76+
getItem: vi.fn(() => null),
77+
removeItem: vi.fn(),
78+
clear: vi.fn(),
79+
},
80+
});
8881
});
8982

9083
afterEach(() => {

0 commit comments

Comments
 (0)