You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
999 B
35 lines
999 B
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import cleanErrorStack from './cleanErrorStack';
|
||
6 years ago
|
|
||
5 years ago
|
describe('Clean Error Stack', function () {
|
||
4 years ago
|
const testMessage = 'Test Message';
|
||
|
const testError = new Error(testMessage);
|
||
|
const undefinedErrorName = new Error(testMessage);
|
||
|
const blankErrorName = new Error(testMessage);
|
||
|
const blankMsgError = new Error();
|
||
6 years ago
|
|
||
5 years ago
|
beforeEach(function () {
|
||
4 years ago
|
undefinedErrorName.name = undefined;
|
||
|
blankErrorName.name = '';
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('tests error with message', function () {
|
||
4 years ago
|
assert.equal(cleanErrorStack(testError), 'Error: Test Message');
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('tests error with undefined name', function () {
|
||
4 years ago
|
assert.equal(
|
||
|
cleanErrorStack(undefinedErrorName).toString(),
|
||
|
'Error: Test Message',
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('tests error with blank name', function () {
|
||
4 years ago
|
assert.equal(cleanErrorStack(blankErrorName).toString(), 'Test Message');
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('tests error with blank message', function () {
|
||
4 years ago
|
assert.equal(cleanErrorStack(blankMsgError), 'Error');
|
||
|
});
|
||
|
});
|