File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
packages/signals/signals/src/lib/storage/__tests__ Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff 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} )
You can’t perform that action at this time.
0 commit comments