You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.4 KiB
54 lines
1.4 KiB
4 years ago
|
// Should occur before anything else
|
||
4 years ago
|
import './globalPatch';
|
||
|
import 'ses/lockdown';
|
||
|
import '../../app/scripts/runLockdown';
|
||
|
import assert from 'assert'; /* eslint-disable-line import/first,import/order */
|
||
5 years ago
|
|
||
5 years ago
|
describe('Promise global is immutable', function () {
|
||
|
it('throws when reassinging promise (syntax 1)', function () {
|
||
5 years ago
|
try {
|
||
4 years ago
|
// eslint-disable-next-line no-global-assign,no-native-reassign
|
||
4 years ago
|
Promise = {};
|
||
|
assert.fail('did not throw error');
|
||
5 years ago
|
} catch (err) {
|
||
4 years ago
|
assert.ok(err, 'did throw error');
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('throws when reassinging promise (syntax 2)', function () {
|
||
5 years ago
|
try {
|
||
4 years ago
|
global.Promise = {};
|
||
|
assert.fail('did not throw error');
|
||
5 years ago
|
} catch (err) {
|
||
4 years ago
|
assert.ok(err, 'did throw error');
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('throws when mutating existing Promise property', function () {
|
||
5 years ago
|
try {
|
||
4 years ago
|
Promise.all = () => undefined;
|
||
|
assert.fail('did not throw error');
|
||
5 years ago
|
} catch (err) {
|
||
4 years ago
|
assert.ok(err, 'did throw error');
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('throws when adding new Promise property', function () {
|
||
5 years ago
|
try {
|
||
4 years ago
|
Promise.foo = 'bar';
|
||
|
assert.fail('did not throw error');
|
||
5 years ago
|
} catch (err) {
|
||
4 years ago
|
assert.ok(err, 'did throw error');
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
5 years ago
|
it('throws when deleting Promise from global', function () {
|
||
5 years ago
|
try {
|
||
4 years ago
|
delete global.Promise;
|
||
|
assert.fail('did not throw error');
|
||
5 years ago
|
} catch (err) {
|
||
4 years ago
|
assert.ok(err, 'did throw error');
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
|
});
|