Skip to content

Commit

Permalink
Avoid running test for sinonjs#1456 on Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
fatso83 committed Jul 13, 2017
1 parent 717ebf7 commit bb2d585
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
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();
});
beforeEach(function () {
if(typeof window === "undefined" || throwsOnUnconfigurableProperty()) { this.skip(); }

it("stub window innerHeight", function () {
sandbox.stub(window, "innerHeight").value(111);
sandbox = sinonSandbox.create();
});

assert.equals(window.innerHeight, 111);
});
afterEach(function () {
sandbox.restore();
});

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

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

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 */
}
});

0 comments on commit bb2d585

Please sign in to comment.