mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
3ba3b330f6
The `assert` module has two modes: "Legacy" and "strict". When using strict mode, the "strict" version of each assertion method is implied. Whereas in legacy mode, by default it will use the deprecated, "loose" version of each assertion. We now use strict mode everywhere. A few tests required updates where they were asserting the wrong thing, and it was passing beforehand due to the loose matching.
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
// Should occur before anything else
|
|
import './globalPatch';
|
|
import 'ses/lockdown';
|
|
import '../../app/scripts/runLockdown';
|
|
import { strict as 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');
|
|
}
|
|
});
|
|
});
|