@@ -42,16 +42,8 @@ describe('LocalStorageEngine Compression Migration', () => {
42
42
return keys [ index ] || null ;
43
43
} ) ;
44
44
45
- const consoleSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
46
-
47
45
new LocalStorageEngine ( mockLocalStorage , 'test' ) ;
48
46
49
- // Should have logged migration
50
- expect ( consoleSpy ) . toHaveBeenCalledWith ( 'Running storage migration from v0 to v1' ) ;
51
- expect ( consoleSpy ) . toHaveBeenCalledWith (
52
- 'Configuration cleanup completed - fresh configs will be compressed' ,
53
- ) ;
54
-
55
47
// Should have removed configuration keys
56
48
expect ( mockLocalStorage . removeItem ) . toHaveBeenCalledWith ( 'eppo-configuration-abc123' ) ;
57
49
expect ( mockLocalStorage . removeItem ) . toHaveBeenCalledWith ( 'eppo-configuration-meta-def456' ) ;
@@ -62,8 +54,6 @@ describe('LocalStorageEngine Compression Migration', () => {
62
54
'eppo-meta' ,
63
55
expect . stringContaining ( '"version":1' ) ,
64
56
) ;
65
-
66
- consoleSpy . mockRestore ( ) ;
67
57
} ) ;
68
58
69
59
it ( 'should skip migration if already completed' , ( ) => {
@@ -73,19 +63,10 @@ describe('LocalStorageEngine Compression Migration', () => {
73
63
return null ;
74
64
} ) ;
75
65
76
- const consoleSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
77
-
78
66
new LocalStorageEngine ( mockLocalStorage , 'test' ) ;
79
67
80
- // Should not have logged migration
81
- expect ( consoleSpy ) . not . toHaveBeenCalledWith (
82
- expect . stringContaining ( 'Running storage migration' ) ,
83
- ) ;
84
-
85
68
// Should not have removed any keys
86
69
expect ( mockLocalStorage . removeItem ) . not . toHaveBeenCalled ( ) ;
87
-
88
- consoleSpy . mockRestore ( ) ;
89
70
} ) ;
90
71
91
72
it ( 'should handle migration errors gracefully' , ( ) => {
@@ -103,13 +84,8 @@ describe('LocalStorageEngine Compression Migration', () => {
103
84
( mockLocalStorage as any ) . _length = 1 ;
104
85
( mockLocalStorage . key as jest . Mock ) . mockReturnValue ( 'eppo-configuration-test' ) ;
105
86
106
- const consoleSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
107
-
108
- new LocalStorageEngine ( mockLocalStorage , 'test' ) ;
109
-
110
- expect ( consoleSpy ) . toHaveBeenCalledWith ( 'Migration failed:' , expect . any ( Error ) ) ;
111
-
112
- consoleSpy . mockRestore ( ) ;
87
+ // Should not throw error, just continue silently
88
+ expect ( ( ) => new LocalStorageEngine ( mockLocalStorage , 'test' ) ) . not . toThrow ( ) ;
113
89
} ) ;
114
90
} ) ;
115
91
@@ -153,8 +129,6 @@ describe('LocalStorageEngine Compression Migration', () => {
153
129
} ) ;
154
130
155
131
it ( 'should handle decompression errors gracefully' , async ( ) => {
156
- const consoleSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
157
-
158
132
// Mock LZString.decompress to throw an error
159
133
const decompressSpy = jest . spyOn ( LZString , 'decompress' ) . mockImplementation ( ( ) => {
160
134
throw new Error ( 'Decompression failed' ) ;
@@ -169,13 +143,9 @@ describe('LocalStorageEngine Compression Migration', () => {
169
143
const result = await engine . getContentsJsonString ( ) ;
170
144
171
145
expect ( result ) . toBe ( null ) ;
172
- expect ( consoleSpy ) . toHaveBeenCalledWith (
173
- 'Failed to decompress configuration, removing corrupted data' ,
174
- ) ;
175
146
expect ( mockLocalStorage . removeItem ) . toHaveBeenCalledWith ( 'eppo-configuration-test' ) ;
176
147
177
148
decompressSpy . mockRestore ( ) ;
178
- consoleSpy . mockRestore ( ) ;
179
149
} ) ;
180
150
181
151
it ( 'should store and retrieve meta data without compression' , async ( ) => {
@@ -228,20 +198,15 @@ describe('LocalStorageEngine Compression Migration', () => {
228
198
} ) ;
229
199
230
200
it ( 'should handle corrupted global meta' , ( ) => {
231
- const consoleSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ) ;
232
-
233
201
( mockLocalStorage . getItem as jest . Mock ) . mockImplementation ( ( key ) => {
234
202
if ( key === 'eppo-meta' ) return 'invalid-json' ;
235
203
return null ;
236
204
} ) ;
237
205
238
206
( mockLocalStorage as any ) . _length = 0 ;
239
207
240
- new LocalStorageEngine ( mockLocalStorage , 'test' ) ;
241
-
242
- expect ( consoleSpy ) . toHaveBeenCalledWith ( 'Failed to parse global meta:' , expect . any ( Error ) ) ;
243
-
244
- consoleSpy . mockRestore ( ) ;
208
+ // Should not throw error, just continue silently with default version
209
+ expect ( ( ) => new LocalStorageEngine ( mockLocalStorage , 'test' ) ) . not . toThrow ( ) ;
245
210
} ) ;
246
211
} ) ;
247
212
0 commit comments