mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +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:
parent
e543fca211
commit
e6cd452506
@ -724,7 +724,9 @@ describe('migration #88', () => {
|
|||||||
expect(newStorage.data).toStrictEqual(oldData);
|
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 = {
|
const oldData = {
|
||||||
TokensController: {},
|
TokensController: {},
|
||||||
NftController: {
|
NftController: {
|
||||||
@ -760,13 +762,15 @@ describe('migration #88', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await migrate(oldStorage);
|
await migrate(oldStorage);
|
||||||
expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
|
expect(mockWarnFn).toHaveBeenCalledTimes(1);
|
||||||
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
|
expect(mockWarnFn).toHaveBeenCalledWith(
|
||||||
new Error(`typeof state.TokenListController is undefined`),
|
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 = {
|
const oldData = {
|
||||||
TokensController: {},
|
TokensController: {},
|
||||||
NftController: {
|
NftController: {
|
||||||
@ -803,8 +807,8 @@ describe('migration #88', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
await migrate(oldStorage);
|
await migrate(oldStorage);
|
||||||
expect(sentryCaptureExceptionMock).toHaveBeenCalledTimes(1);
|
expect(mockWarnFn).toHaveBeenCalledTimes(1);
|
||||||
expect(sentryCaptureExceptionMock).toHaveBeenCalledWith(
|
expect(mockWarnFn).toHaveBeenCalledWith(
|
||||||
new Error(`typeof state.TokenListController is boolean`),
|
new Error(`typeof state.TokenListController is boolean`),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -164,7 +164,7 @@ function migrateData(state: Record<string, unknown>): void {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
global.sentry?.captureException?.(
|
console.warn(
|
||||||
new Error(
|
new Error(
|
||||||
`typeof state.TokenListController is ${typeof state.TokenListController}`,
|
`typeof state.TokenListController is ${typeof state.TokenListController}`,
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user