mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
c11888f287
See [`no-empty-function`](https://eslint.org/docs/rules/no-empty-function) for more information. This change enables `no-empty-function` and fixes the issues raised by the rule.
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
import '../../app/scripts/lib/freezeGlobals'
|
|
|
|
import assert from 'assert'
|
|
|
|
describe('Promise global is immutable', function () {
|
|
|
|
it('throws when reassinging promise (syntax 1)', function () {
|
|
try {
|
|
// eslint-disable-next-line no-global-assign,no-native-reassign
|
|
Promise = {}
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when reassinging promise (syntax 2)', function () {
|
|
try {
|
|
global.Promise = {}
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when mutating existing Promise property', function () {
|
|
try {
|
|
Promise.all = () => undefined
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when adding new Promise property', function () {
|
|
try {
|
|
Promise.foo = 'bar'
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when deleting Promise from global', function () {
|
|
try {
|
|
delete global.Promise
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
})
|