1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 12:56:01 +01:00
metamask-extension/test/unit/app/cleanErrorStack.spec.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

35 lines
1022 B
JavaScript

import assert from 'assert';
import cleanErrorStack from '../../../app/scripts/lib/cleanErrorStack';
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();
beforeEach(function () {
undefinedErrorName.name = undefined;
blankErrorName.name = '';
});
it('tests error with message', function () {
assert.equal(cleanErrorStack(testError), 'Error: Test Message');
});
it('tests error with undefined name', function () {
assert.equal(
cleanErrorStack(undefinedErrorName).toString(),
'Error: Test Message',
);
});
it('tests error with blank name', function () {
assert.equal(cleanErrorStack(blankErrorName).toString(), 'Test Message');
});
it('tests error with blank message', function () {
assert.equal(cleanErrorStack(blankMsgError), 'Error');
});
});