diff --git a/lib/sinon/util/fake_server.js b/lib/sinon/util/fake_server.js index 76b9d3fad..100f0ab39 100644 --- a/lib/sinon/util/fake_server.js +++ b/lib/sinon/util/fake_server.js @@ -100,6 +100,9 @@ var fakeServer = { this.xhr = fakeXhr.useFakeXMLHttpRequest(); server.requests = []; server.requestCount = 0; + server.queue = []; + server.responses = []; + this.xhr.onCreate = function (xhrObj) { xhrObj.unsafeHeadersEnabled = function () { @@ -166,10 +169,6 @@ var fakeServer = { handleRequest: function handleRequest(xhr) { if (xhr.async) { - if (!this.queue) { - this.queue = []; - } - push.call(this.queue, xhr); } else { this.processRequest(xhr); @@ -199,10 +198,6 @@ var fakeServer = { return; } - if (!this.responses) { - this.responses = []; - } - if (arguments.length === 1) { body = method; url = method = null; diff --git a/test/sandbox-test.js b/test/sandbox-test.js index b3176c9a5..46d1d48d9 100644 --- a/test/sandbox-test.js +++ b/test/sandbox-test.js @@ -56,6 +56,22 @@ describe("sinonSandbox", function () { assert.same(sandbox.assert, sinonAssert); }); + it("can be reset without failing when pre-configured to use a fake server", function () { + var sandbox = sinonSandbox.create({useFakeServer: true}); + refute.exception(function () { + sandbox.reset(); + }); + }); + + it("can be reset without failing when configured to use a fake server", function () { + var sandbox = sinonSandbox.create(); + sandbox.useFakeServer(); + refute.exception(function () { + sandbox.reset(); + }); + }); + + describe(".useFakeTimers", function () { beforeEach(function () { this.sandbox = Object.create(sinonSandbox);