Skip to content

Commit

Permalink
Fix test failures with Sinon 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
glasserc committed Aug 10, 2017
1 parent 9f01b1d commit bb1a398
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions test/collection_test.js
Expand Up @@ -2360,7 +2360,7 @@ describe("Collection", () => {
deleteRecord = batchSpy.expects("deleteRecord");
createRecord = batchSpy.expects("createRecord");
updateRecord = batchSpy.expects("updateRecord");
sandbox.stub(KintoClientCollection.prototype, "batch", f => {
sandbox.stub(KintoClientCollection.prototype, "batch").callsFake(f => {
f(batch);
return Promise.resolve({
published: [],
Expand Down Expand Up @@ -2654,9 +2654,11 @@ describe("Collection", () => {

it("should not execute a last pull on push failure", () => {
const pullChanges = sandbox.stub(articles, "pullChanges");
sandbox.stub(articles, "pushChanges", (client, changes, result) => {
result.add("conflicts", [1]);
});
sandbox
.stub(articles, "pushChanges")
.callsFake((client, changes, result) => {
result.add("conflicts", [1]);
});
return articles.sync().then(() => sinon.assert.calledOnce(pullChanges));
});

Expand All @@ -2674,10 +2676,12 @@ describe("Collection", () => {
const record1 = { id: uuid4(), title: "blog" };
const record2 = { id: uuid4(), title: "post" };
sandbox.stub(articles, "pullChanges");
sandbox.stub(articles, "pushChanges", (client, changes, result) => {
result.add("published", record1);
result.add("published", record2);
});
sandbox
.stub(articles, "pushChanges")
.callsFake((client, changes, result) => {
result.add("published", record1);
result.add("published", record2);
});
return articles.sync().then(res => {
expect(res.published).to.have.length(2);
expect(articles.pullChanges.lastCall.args[2].exclude).eql([
Expand Down Expand Up @@ -2776,7 +2780,7 @@ describe("Collection", () => {
// Last pull
fetch.onCall(4).returns(fakeServerResponse(200, { data: [] }, {}));
// Avoid actually waiting real time between retries in test suites.
sandbox.stub(global, "setTimeout", fn => setImmediate(fn));
sandbox.stub(global, "setTimeout").callsFake(fn => setImmediate(fn));
});

it("should retry if specified", () => {
Expand Down

0 comments on commit bb1a398

Please sign in to comment.