Skip to content

Commit e97d2c7

Browse files
committed
wip
1 parent f4900f5 commit e97d2c7

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

packages/signals/signals/src/lib/storage/__tests__/web-storage.test.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,23 @@ describe('WebStorage', () => {
2828
expect(result).toBeUndefined()
2929
})
3030

31-
it('should handle JSON parsing errors gracefully', () => {
31+
it('should handle JSON serializing errors gracefully when setting', () => {
32+
const key = 'testKey'
33+
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation()
34+
35+
webStorage.setItem(
36+
key,
37+
// @ts-ignore
38+
undefined
39+
)
40+
41+
const result = webStorage.getItem(key)
42+
43+
expect(result).toBeUndefined()
44+
expect(consoleWarnSpy).toHaveBeenCalledTimes(1)
45+
})
46+
47+
it('should handle JSON parsing errors gracefully when retrieving', () => {
3248
const key = 'testKey'
3349
const consoleWarnSpy = jest.spyOn(console, 'warn').mockImplementation()
3450

@@ -39,7 +55,6 @@ describe('WebStorage', () => {
3955

4056
expect(result).toBeUndefined()
4157
expect(consoleWarnSpy).toHaveBeenCalledTimes(1)
42-
consoleWarnSpy.mockRestore()
4358
})
4459
})
4560
})

0 commit comments

Comments
 (0)