Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch fake server without clock #1648

Merged
merged 3 commits into from
Jan 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ before_script:
# ESLint only supports Node >=4
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run lint; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run lint-markdown; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run test-headless; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run test-webworker; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run test-headless -- --allow-chrome-as-root; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ]; then npm run test-webworker -- --allow-chrome-as-root; fi
- if [ "x$TRAVIS_NODE_VERSION" = "x8" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test-cloud; fi

script:
Expand Down
3 changes: 1 addition & 2 deletions lib/sinon/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ var sinonAssert = require("./assert");
var sinonClock = require("./util/fake_timers");
var fakeServer = require("nise").fakeServer;
var fakeXhr = require("nise").fakeXhr;
var fakeServerWithClock = require("nise").fakeServerWithClock;

var push = [].push;

Expand Down Expand Up @@ -55,7 +54,7 @@ extend(sinonSandbox, {
return this.add(this.clock);
},

serverPrototype: fakeServerWithClock,
serverPrototype: fakeServer,

useFakeServer: function useFakeServer() {
var proto = this.serverPrototype || fakeServer;
Expand Down
133 changes: 84 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion test/sandbox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,13 @@ describe("sinonSandbox", function () {
assert(fakeServer.isPrototypeOf(server));
});

it("creates server with cock", function () {
it("creates server without clock by default", function () {
var server = this.sandbox.useFakeServer();

refute(fakeServerWithClock.isPrototypeOf(server));
});

it("creates server with clock", function () {
this.sandbox.serverPrototype = fakeServerWithClock;
var server = this.sandbox.useFakeServer();

Expand Down Expand Up @@ -472,6 +478,20 @@ describe("sinonSandbox", function () {
sandbox.restore();
});

it("uses fakeServer as the serverPrototype by default", function () {
var sandbox = sinonSandbox.create();

assert.same(sandbox.serverPrototype, fakeServer);
});

it("uses configured implementation as the serverPrototype", function () {
var sandbox = sinonSandbox.create({
useFakeServer: fakeServerWithClock
});

assert.same(sandbox.serverPrototype, fakeServerWithClock);
});

it("yields clock when faking timers", function () {
var sandbox = sinonSandbox.create(sinonConfig({
injectIntoThis: false,
Expand Down