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