Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: stop modifying globals in Proxy tests #1144

Merged
merged 1 commit into from Mar 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 18 additions & 55 deletions test/utilities.js
Expand Up @@ -1284,81 +1284,44 @@ describe('utilities', function () {
});

describe("isProxyEnabled", function () {
if (typeof Proxy === 'undefined' || typeof Reflect === 'undefined') return;

var origProxy, origReflect, origUseProxy, isProxyEnabled;
var origUseProxy, isProxyEnabled;

before(function () {
chai.use(function (_chai, _) {
isProxyEnabled = _.isProxyEnabled;
});

origProxy = Proxy;
origReflect = Reflect;
origUseProxy = chai.config.useProxy;
});

beforeEach(function () {
Proxy = origProxy;
Reflect = origReflect;
chai.config.useProxy = true;
});

after(function () {
Proxy = origProxy;
Reflect = origReflect;
chai.config.useProxy = origUseProxy;
});

it("returns true if Proxy is defined, Reflect is defined, and useProxy is true", function () {
expect(isProxyEnabled()).to.be.true;
});

it("returns false if Proxy is defined, Reflect is defined, and useProxy is false", function () {
chai.config.useProxy = false;

expect(isProxyEnabled()).to.be.false;
});

it("returns false if Proxy is defined, Reflect is undefined, and useProxy is true", function () {
Reflect = undefined;

expect(isProxyEnabled()).to.be.false;
});

it("returns false if Proxy is defined, Reflect is undefined, and useProxy is false", function () {
Reflect = undefined;
chai.config.useProxy = false;

expect(isProxyEnabled()).to.be.false;
});

it("returns false if Proxy is undefined, Reflect is defined, and useProxy is true", function () {
Proxy = undefined;

expect(isProxyEnabled()).to.be.false;
});

it("returns false if Proxy is undefined, Reflect is defined, and useProxy is false", function () {
Proxy = undefined;
chai.config.useProxy = false;

expect(isProxyEnabled()).to.be.false;
});
if (typeof Proxy !== 'undefined' && typeof Reflect !== 'undefined') {
it("returns true if Proxy and Reflect are defined, and useProxy is true", function () {
expect(isProxyEnabled()).to.be.true;
});

it("returns false if Proxy is undefined, Reflect is undefined, and useProxy is true", function () {
Proxy = undefined;
Reflect = undefined;
it("returns false if Proxy and Reflect are defined, and useProxy is false", function () {
chai.config.useProxy = false;

expect(isProxyEnabled()).to.be.false;
});
expect(isProxyEnabled()).to.be.false;
});
} else {
it("returns false if Proxy and/or Reflect are undefined, and useProxy is true", function () {
expect(isProxyEnabled()).to.be.false;
});

it("returns false if Proxy is undefined, Reflect is undefined, and useProxy is false", function () {
Proxy = undefined;
Reflect = undefined;
chai.config.useProxy = false;
it("returns false if Proxy and/or Reflect are undefined, and useProxy is false", function () {
chai.config.useProxy = false;

expect(isProxyEnabled()).to.be.false;
});
expect(isProxyEnabled()).to.be.false;
});
}
});
});