Skip to content

Commit

Permalink
Fix: unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gyandeeps committed Jun 20, 2017
1 parent ae274c3 commit 2c88a7e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
21 changes: 21 additions & 0 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var referee = require("referee");
var sinon = require("../../lib/sinon");
var sinonSandbox = require("../../lib/sinon/sandbox");
var configureLogError = require("../../lib/sinon/util/core/log_error.js");
var assert = referee.assert;
var refute = referee.refute;
Expand Down Expand Up @@ -248,4 +249,24 @@ describe("issues", function () {
});
});
});

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

beforeEach(function () {
sandbox = sinonSandbox.create();
});

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

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

assert.equals(window.innerHeight, 111);
});
});
}
});
20 changes: 0 additions & 20 deletions test/sandbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,24 +626,4 @@ describe("sinonSandbox", function () {
assert.equals(object.prop, "bla");
});
});

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

beforeEach(function () {
sandbox = sinonSandbox.create();
});

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

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

assert.equals(window.innerHeight, 111);
});
});
}
});
13 changes: 13 additions & 0 deletions test/stub-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2672,5 +2672,18 @@ describe("stub", function () {

assert.equals(myFunc.prop, "rawString");
});

it("allows stubbing object props with configurable false", function () {
var myObj = {};
Object.defineProperty(myObj, "prop", {
configurable: false,
enumerable: true,
writable: true,
value: "static"
});

createStub(myObj, "prop").value("newString");
assert.equals(myObj.prop, "newString");
});
});
});

0 comments on commit 2c88a7e

Please sign in to comment.