1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-22 09:23:21 +01:00

fix: Remove sentry warning on undefined TokenListController (#20547)

* fix sentry warning

* correct test

* switch to using spyOn method
This commit is contained in:
Pedro Figueiredo 2023-08-22 15:06:18 +01:00 committed by GitHub
parent e543fca211
commit e6cd452506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -724,7 +724,9 @@ describe('migration #88', () => {
expect(newStorage.data).toStrictEqual(oldData);
});
it('captures an exception if it has no TokenListController property', async () => {
it('logs a warning if it has no TokenListController property', async () => {
const mockWarnFn = jest.spyOn(console, 'warn');
const oldData = {
TokensController: {},
NftController: {
@ -760,13 +762,15 @@ describe('migration #88', () => {
};
await migrate(oldStorage);
expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
expect(mockWarnFn).toHaveBeenCalledTimes(1);
expect(mockWarnFn).toHaveBeenCalledWith(
new Error(`typeof state.TokenListController is undefined`),
);
});
it('captures an exception if the TokenListController property is not an object', async () => {
it('logs a warning if the TokenListController property is not an object', async () => {
const mockWarnFn = jest.spyOn(console, 'warn');
const oldData = {
TokensController: {},
NftController: {
@ -803,8 +807,8 @@ describe('migration #88', () => {
};
await migrate(oldStorage);
expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
expect(mockWarnFn).toHaveBeenCalledTimes(1);
expect(mockWarnFn).toHaveBeenCalledWith(
new Error(`typeof state.TokenListController is boolean`),
);
});

View File

@ -164,7 +164,7 @@ function migrateData(state: Record<string, unknown>): void {
);
}
} else {
global.sentry?.captureException?.(
console.warn(
new Error(
`typeof state.TokenListController is ${typeof state.TokenListController}`,
),