From 860865588630bf558bdafd4efc5d2f31c2a13c0c Mon Sep 17 00:00:00 2001 From: Danica Shen Date: Tue, 5 Sep 2023 16:57:19 +0100 Subject: [PATCH] fix(20548): fix warning levels in migration file (#20737) --- app/scripts/migrations/088.test.ts | 21 +++++++++++++-------- app/scripts/migrations/088.ts | 6 ++---- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/scripts/migrations/088.test.ts b/app/scripts/migrations/088.test.ts index e60446109..51f9ebcd2 100644 --- a/app/scripts/migrations/088.test.ts +++ b/app/scripts/migrations/088.test.ts @@ -1,5 +1,8 @@ +import log from 'loglevel'; import { migrate } from './088'; +jest.mock('loglevel'); + const sentryCaptureExceptionMock = jest.fn(); global.sentry = { @@ -725,7 +728,7 @@ describe('migration #88', () => { }); it('logs a warning if it has no TokenListController property', async () => { - const mockWarnFn = jest.spyOn(console, 'warn'); + const mockWarnFn = jest.spyOn(log, 'warn'); const oldData = { TokensController: {}, @@ -762,14 +765,15 @@ describe('migration #88', () => { }; await migrate(oldStorage); - expect(mockWarnFn).toHaveBeenCalledTimes(1); - expect(mockWarnFn).toHaveBeenCalledWith( - new Error(`typeof state.TokenListController is undefined`), + expect(mockWarnFn).toHaveBeenCalledTimes(4); + expect(mockWarnFn).toHaveBeenNthCalledWith( + 1, + 'typeof state.TokenListController is undefined', ); }); it('logs a warning if the TokenListController property is not an object', async () => { - const mockWarnFn = jest.spyOn(console, 'warn'); + const mockWarnFn = jest.spyOn(log, 'warn'); const oldData = { TokensController: {}, @@ -807,9 +811,10 @@ describe('migration #88', () => { }; await migrate(oldStorage); - expect(mockWarnFn).toHaveBeenCalledTimes(1); - expect(mockWarnFn).toHaveBeenCalledWith( - new Error(`typeof state.TokenListController is boolean`), + expect(mockWarnFn).toHaveBeenCalledTimes(4); + expect(mockWarnFn).toHaveBeenNthCalledWith( + 1, + 'typeof state.TokenListController is boolean', ); }); diff --git a/app/scripts/migrations/088.ts b/app/scripts/migrations/088.ts index 031a1184e..6fda62183 100644 --- a/app/scripts/migrations/088.ts +++ b/app/scripts/migrations/088.ts @@ -164,10 +164,8 @@ function migrateData(state: Record): void { ); } } else { - console.warn( - new Error( - `typeof state.TokenListController is ${typeof state.TokenListController}`, - ), + log.warn( + `typeof state.TokenListController is ${typeof state.TokenListController}`, ); }