Skip to content

Commit 9885c39

Browse files
committed
remove console spy
1 parent d167e03 commit 9885c39

File tree

2 files changed

+5
-41
lines changed

2 files changed

+5
-41
lines changed

src/local-storage-engine.spec.ts

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,8 @@ describe('LocalStorageEngine Compression Migration', () => {
4242
return keys[index] || null;
4343
});
4444

45-
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
46-
4745
new LocalStorageEngine(mockLocalStorage, 'test');
4846

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-
5547
// Should have removed configuration keys
5648
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('eppo-configuration-abc123');
5749
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('eppo-configuration-meta-def456');
@@ -62,8 +54,6 @@ describe('LocalStorageEngine Compression Migration', () => {
6254
'eppo-meta',
6355
expect.stringContaining('"version":1'),
6456
);
65-
66-
consoleSpy.mockRestore();
6757
});
6858

6959
it('should skip migration if already completed', () => {
@@ -73,19 +63,10 @@ describe('LocalStorageEngine Compression Migration', () => {
7363
return null;
7464
});
7565

76-
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
77-
7866
new LocalStorageEngine(mockLocalStorage, 'test');
7967

80-
// Should not have logged migration
81-
expect(consoleSpy).not.toHaveBeenCalledWith(
82-
expect.stringContaining('Running storage migration'),
83-
);
84-
8568
// Should not have removed any keys
8669
expect(mockLocalStorage.removeItem).not.toHaveBeenCalled();
87-
88-
consoleSpy.mockRestore();
8970
});
9071

9172
it('should handle migration errors gracefully', () => {
@@ -103,13 +84,8 @@ describe('LocalStorageEngine Compression Migration', () => {
10384
(mockLocalStorage as any)._length = 1;
10485
(mockLocalStorage.key as jest.Mock).mockReturnValue('eppo-configuration-test');
10586

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();
11389
});
11490
});
11591

@@ -153,8 +129,6 @@ describe('LocalStorageEngine Compression Migration', () => {
153129
});
154130

155131
it('should handle decompression errors gracefully', async () => {
156-
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation();
157-
158132
// Mock LZString.decompress to throw an error
159133
const decompressSpy = jest.spyOn(LZString, 'decompress').mockImplementation(() => {
160134
throw new Error('Decompression failed');
@@ -169,13 +143,9 @@ describe('LocalStorageEngine Compression Migration', () => {
169143
const result = await engine.getContentsJsonString();
170144

171145
expect(result).toBe(null);
172-
expect(consoleSpy).toHaveBeenCalledWith(
173-
'Failed to decompress configuration, removing corrupted data',
174-
);
175146
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('eppo-configuration-test');
176147

177148
decompressSpy.mockRestore();
178-
consoleSpy.mockRestore();
179149
});
180150

181151
it('should store and retrieve meta data without compression', async () => {
@@ -228,20 +198,15 @@ describe('LocalStorageEngine Compression Migration', () => {
228198
});
229199

230200
it('should handle corrupted global meta', () => {
231-
const consoleSpy = jest.spyOn(console, 'warn').mockImplementation();
232-
233201
(mockLocalStorage.getItem as jest.Mock).mockImplementation((key) => {
234202
if (key === 'eppo-meta') return 'invalid-json';
235203
return null;
236204
});
237205

238206
(mockLocalStorage as any)._length = 0;
239207

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();
245210
});
246211
});
247212

src/local-storage-engine.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class LocalStorageEngine implements IStringStorageEngine {
4242
try {
4343
return LZString.decompress(stored) || null;
4444
} catch (e) {
45-
console.warn('Failed to decompress configuration, removing corrupted data');
45+
// Failed to decompress configuration, removing corrupted data
4646
this.localStorage.removeItem(this.contentsKey);
4747
return null;
4848
}
@@ -75,7 +75,6 @@ export class LocalStorageEngine implements IStringStorageEngine {
7575
migratedAt: Date.now(),
7676
version: LocalStorageEngine.MIGRATION_VERSION,
7777
});
78-
7978
} catch (e) {
8079
// Migration failed, continue silently
8180
}

0 commit comments

Comments
 (0)