1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/lib/cleanErrorStack.test.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

import { strict as assert } from 'assert';
import cleanErrorStack from './cleanErrorStack';
2018-09-24 18:28:04 +02:00
describe('Clean Error Stack', function () {
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(function () {
undefinedErrorName.name = undefined;
blankErrorName.name = '';
});
2018-09-24 18:28:04 +02:00
it('tests error with message', function () {
assert.equal(cleanErrorStack(testError).toString(), 'Error: Test Message');
});
2018-09-24 18:28:04 +02:00
it('tests error with undefined name', function () {
2020-11-03 00:41:28 +01:00
assert.equal(
cleanErrorStack(undefinedErrorName).toString(),
'Error: Test Message',
);
});
2018-09-24 18:28:04 +02:00
it('tests error with blank name', function () {
assert.equal(cleanErrorStack(blankErrorName).toString(), 'Test Message');
});
2018-09-24 18:28:04 +02:00
it('tests error with blank message', function () {
assert.equal(cleanErrorStack(blankMsgError).toString(), 'Error');
});
});