1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/app/scripts/lib/cleanErrorStack.test.js

37 lines
1008 B
JavaScript
Raw Normal View History

import cleanErrorStack from './cleanErrorStack';
2018-09-24 18:28:04 +02:00
describe('Clean Error Stack', () => {
const testMessage = 'Test Message';
const testError = new Error(testMessage);
const undefinedErrorName = new Error(testMessage);
const blankErrorName = new Error(testMessage);
const blankMsgError = new Error();
2018-09-24 18:28:04 +02:00
beforeEach(() => {
undefinedErrorName.name = undefined;
blankErrorName.name = '';
});
2018-09-24 18:28:04 +02:00
it('tests error with message', () => {
expect(cleanErrorStack(testError).toString()).toStrictEqual(
'Error: Test Message',
);
});
2018-09-24 18:28:04 +02:00
it('tests error with undefined name', () => {
expect(cleanErrorStack(undefinedErrorName).toString()).toStrictEqual(
2020-11-03 00:41:28 +01:00
'Error: Test Message',
);
});
2018-09-24 18:28:04 +02:00
it('tests error with blank name', () => {
expect(cleanErrorStack(blankErrorName).toString()).toStrictEqual(
'Test Message',
);
});
2018-09-24 18:28:04 +02:00
it('tests error with blank message', () => {
expect(cleanErrorStack(blankMsgError).toString()).toStrictEqual('Error');
});
});