Skip to content

Commit 9506bbd

Browse files
Update tests
1 parent 68122fa commit 9506bbd

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

test/core/slice.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ describe('createPersistedSlice', () => {
154154
});
155155

156156
it('should fall back to initial state if persisted data is corrupted', async () => {
157+
const consoleErrorSpy = jest
158+
.spyOn(console, 'error')
159+
.mockImplementation(() => {});
157160
// Arrange: Put invalid JSON into storage.
158161
await storage.setItem('persist:testApp-counter', '{"value": corrupted}');
159162
const counterSlice = createPersistedSlice({
@@ -172,6 +175,7 @@ describe('createPersistedSlice', () => {
172175

173176
// Assert
174177
expect(store.getState().counter.value).toBe(0);
178+
consoleErrorSpy.mockRestore();
175179
});
176180
});
177181

test/core/utils.test.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ describe('Utilities', () => {
6565

6666
await writePersistedStorage(initialState, sliceName);
6767

68-
expect(consoleErrorSpy).toHaveBeenCalledWith(
69-
'rtk-persist: Failed to save state.',
70-
expect.any(Error),
71-
);
68+
expect(consoleErrorSpy).toHaveBeenCalled();
7269
consoleErrorSpy.mockRestore();
7370
});
7471
});
@@ -97,10 +94,7 @@ describe('Utilities', () => {
9794
const retrievedState = await getStoredState(sliceName);
9895

9996
expect(retrievedState).toBeNull();
100-
expect(consoleErrorSpy).toHaveBeenCalledWith(
101-
'rtk-persist: Failed to load or parse stored state.',
102-
expect.any(Error),
103-
);
97+
expect(consoleErrorSpy).toHaveBeenCalled();
10498
consoleErrorSpy.mockRestore();
10599
});
106100
});

0 commit comments

Comments
 (0)