1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

fix(20548): fix warning levels in migration file (#20737)

This commit is contained in:
Danica Shen 2023-09-05 16:57:19 +01:00 committed by GitHub
parent 0962e85a1b
commit 8608655886
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 12 deletions

View File

@ -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',
);
});

View File

@ -164,10 +164,8 @@ function migrateData(state: Record<string, unknown>): void {
);
}
} else {
console.warn(
new Error(
`typeof state.TokenListController is ${typeof state.TokenListController}`,
),
log.warn(
`typeof state.TokenListController is ${typeof state.TokenListController}`,
);
}