1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 23:58:06 +01:00
metamask-extension/test/unit/app/cleanErrorStack.spec.js

35 lines
1003 B
JavaScript
Raw Normal View History

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