Skip to content

Commit

Permalink
Merge pull request #1144 from meeber/fix-proxy-tests
Browse files Browse the repository at this point in the history
test: stop modifying globals in Proxy tests
  • Loading branch information
astorije committed Mar 4, 2018
2 parents 97e2493 + d89a9fe commit 3bd8d93
Showing 1 changed file with 18 additions and 55 deletions.
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;
});
}
});
});

0 comments on commit 3bd8d93

Please sign in to comment.