1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 16:18:07 +01:00
metamask-extension/app/scripts/lib/cleanErrorStack.test.js
Mark Stacey f47cfbbb3e
Use strict assertion mode everywhere (#11012)
The `assert` module has two modes: "Legacy" and "strict". When using
strict mode, the "strict" version of each assertion method is implied.
Whereas in legacy mode, by default it will use the deprecated, "loose"
version of each assertion.

We now use strict mode everywhere. A few tests required updates where
they were asserting the wrong thing, and it was passing beforehand due
to the loose matching.
2021-05-07 17:08:24 -02:30

35 lines
1.0 KiB
JavaScript

import { strict as assert } from 'assert';
import cleanErrorStack from './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).toString(), '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).toString(), 'Error');
});
});