1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/test/unit-global/frozenPromise.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

54 lines
1.4 KiB
JavaScript

// Should occur before anything else
import './globalPatch';
import 'ses/lockdown';
import '../../app/scripts/runLockdown';
import assert from 'assert'; /* eslint-disable-line import/first,import/order */
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');
}
});
});