mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
92971d3c87
* Update eslint-plugin-import version * Convert JS files to use ESM * Update ESLint rules to check imports * Fix test:unit:global command env * Cleanup mock-dev script
56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
|
|
/* eslint-disable no-native-reassign */
|
|
|
|
// this is what we're testing
|
|
import '../../app/scripts/lib/freezeGlobals'
|
|
|
|
import assert from 'assert'
|
|
|
|
describe('Promise global is immutable', () => {
|
|
|
|
it('throws when reassinging promise (syntax 1)', () => {
|
|
try {
|
|
Promise = {}
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when reassinging promise (syntax 2)', () => {
|
|
try {
|
|
global.Promise = {}
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when mutating existing Promise property', () => {
|
|
try {
|
|
Promise.all = () => {}
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
|
|
it('throws when adding new Promise property', () => {
|
|
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', () => {
|
|
try {
|
|
delete global.Promise
|
|
assert.fail('did not throw error')
|
|
} catch (err) {
|
|
assert.ok(err, 'did throw error')
|
|
}
|
|
})
|
|
})
|