Skip to content

Commit 75d9530

Browse files
committed
♻️ Enhance localStorage mock implementation (#1726)
1 parent b609931 commit 75d9530

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/test/lib/stores/replenishment_workbook.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ vi.mock('$app/environment', () => ({
88

99
describe('Replenishment workbooks store', () => {
1010
const localStorageKey = 'is_shown_replenishment_workbooks';
11-
const mockLocalStorage = {
11+
const mockLocalStorage: Storage = {
1212
getItem: vi.fn(),
1313
setItem: vi.fn(),
1414
removeItem: vi.fn(),
1515
clear: vi.fn(),
16+
length: 0,
17+
key: vi.fn(),
1618
};
1719

1820
beforeEach(() => {
@@ -45,7 +47,7 @@ describe('Replenishment workbooks store', () => {
4547

4648
// Note: This test is skipped because it is not possible to mock localStorage in JSDOM.
4749
test.skip('persists state in localStorage', () => {
48-
mockLocalStorage.getItem.mockReturnValue(JSON.stringify(false));
50+
(mockLocalStorage.getItem as jest.Mock).mockReturnValue(JSON.stringify(false));
4951

5052
replenishmentWorkBooksStore.toggleView();
5153

0 commit comments

Comments
 (0)