Skip to content

Commit

Permalink
Merge pull request #1532 from EyalAr/master
Browse files Browse the repository at this point in the history
Fix for `sinon.createFakeServer()` exception
  • Loading branch information
fatso83 authored Aug 17, 2017
2 parents 4310343 + 4f40409 commit d9cae73
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/sinon.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ exports.fakeServer = nise.fakeServer;
exports.fakeServerWithClock = nise.fakeServerWithClock;

exports.createSandbox = sandbox.create;
exports.createFakeServer = nise.fakeServer.create;
exports.createFakeServerWithClock = nise.fakeServerWithClock.create;
exports.createFakeServer = nise.fakeServer.create.bind(nise.fakeServer);
exports.createFakeServerWithClock = nise.fakeServerWithClock.create.bind(nise.fakeServerWithClock);

var behavior = require("./sinon/behavior");

Expand Down
14 changes: 14 additions & 0 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,18 @@ describe("issues", function () {
});

});

describe("#1531 - some copied functions on root sinon module throw", function () {
it("should create a fake server without throwing", function () {
refute.exception(function () {
sinon.createFakeServer();
});
});

it("should create a fake server with clock without throwing", function () {
refute.exception(function () {
sinon.createFakeServerWithClock();
});
});
});
});
12 changes: 8 additions & 4 deletions test/sinon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ describe("sinon module", function () {

fakeNise = {
fakeServer: {
create: "47c86a4c-6b48-4748-bb8c-d853f999720c"
create: function () {
return "47c86a4c-6b48-4748-bb8c-d853f999720c";
}
},
fakeServerWithClock: {
create: "e69974f8-4568-48d1-a5e9-2b511a59c14b"
create: function () {
return "e69974f8-4568-48d1-a5e9-2b511a59c14b";
}
},
fakeXhr: {
xhr: "958e8996-0cc3-4136-8a0e-6a120f5311bc",
Expand Down Expand Up @@ -52,7 +56,7 @@ describe("sinon module", function () {

describe("createFakeServer", function () {
it("should be fakeServer.create from nise", function () {
assert.equals(sinon.createFakeServer, fakeNise.fakeServer.create);
assert.equals(sinon.createFakeServer(), fakeNise.fakeServer.create());
});
});

Expand All @@ -64,7 +68,7 @@ describe("sinon module", function () {

describe("createFakeServerWithClock", function () {
it("should be fakeServerWithClock.create from nise", function () {
assert.equals(sinon.createFakeServerWithClock, fakeNise.fakeServerWithClock.create);
assert.equals(sinon.createFakeServerWithClock(), fakeNise.fakeServerWithClock.create());
});
});

Expand Down

0 comments on commit d9cae73

Please sign in to comment.