Skip to content

Commit

Permalink
Merge pull request #1481 from fatso83/fix-safari-breaking
Browse files Browse the repository at this point in the history
Avoid running test for #1456 on Safari
  • Loading branch information
mroderick committed Jul 15, 2017
2 parents e742268 + 24d15f2 commit 259a330
Showing 1 changed file with 30 additions and 17 deletions.
47 changes: 30 additions & 17 deletions test/issues/issues-test.js
Expand Up @@ -7,7 +7,6 @@ var configureLogError = require("../../lib/sinon/util/core/log_error.js");
var assert = referee.assert;
var refute = referee.refute;


describe("issues", function () {
beforeEach(function () {
this.sandbox = sinon.sandbox.create();
Expand Down Expand Up @@ -210,10 +209,10 @@ describe("issues", function () {
var argsB = match(suffixB);

var firstFake = readFile
.withArgs(argsA);
.withArgs(argsA);

var secondFake = readFile
.withArgs(argsB);
.withArgs(argsB);

assert(firstFake !== secondFake);
});
Expand Down Expand Up @@ -282,23 +281,37 @@ describe("issues", function () {
});
});

if (typeof window !== "undefined") {
describe("#1456", function () {
var sandbox;

beforeEach(function () {
sandbox = sinonSandbox.create();
});
describe("#1456", function () {
var sandbox;

afterEach(function () {
sandbox.restore();
});
function throwsOnUnconfigurableProperty() {
/* eslint-disable no-restricted-syntax */
try {
var preDescriptor = Object.getOwnPropertyDescriptor(window, "innerHeight"); //backup val
Object.defineProperty(window, "innerHeight", { value: 10, configureable: true, writeable: true });
Object.defineProperty(window, "innerHeight", preDescriptor); //restore
return false;
} catch (err) {
return true;
}
/* eslint-enable no-restricted-syntax */
}

it("stub window innerHeight", function () {
sandbox.stub(window, "innerHeight").value(111);
beforeEach(function () {
if (typeof window === "undefined" || throwsOnUnconfigurableProperty()) { this.skip(); }

assert.equals(window.innerHeight, 111);
});
sandbox = sinonSandbox.create();
});
}

afterEach(function () {
sandbox.restore();
});

it("stub window innerHeight", function () {
sandbox.stub(window, "innerHeight").value(111);

assert.equals(window.innerHeight, 111);
});
});
});

0 comments on commit 259a330

Please sign in to comment.