Github user kxepal commented on a diff in the pull request: https://github.com/apache/couchdb-fauxton/pull/324#discussion_r26830370 --- Diff: app/addons/documents/tests/resourcesSpec.js --- @@ -233,28 +238,61 @@ define([ collection.handleResponse([ {"ok":true,"id":"Deferred","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, {"ok":true,"id":"DeskSet","rev":"6-da537822b9672a4b2f42adb1be04a5b1"} - ]); + ], promise); }); it("triggers a error event with all errored ids", function () { + var promise = FauxtonAPI.Deferred(); + collection.listenToOnce(collection, 'error', function (ids) { assert.deepEqual(ids, ['Deferred']); }); collection.handleResponse([ - {"error":"confclict","id":"Deferred","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, + {"error":"conflict","id":"Deferred","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, {"ok":true,"id":"DeskSet","rev":"6-da537822b9672a4b2f42adb1be04a5b1"} - ]); + ], promise); }); it("removes successfull deleted from the collection but keeps one with errors", function () { + var promise = FauxtonAPI.Deferred(); collection.handleResponse([ {"error":"confclict","id":"1","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, {"ok":true,"id":"2","rev":"6-da537822b9672a4b2f42adb1be04a5b1"}, {"error":"conflict","id":"3","rev":"6-da537822b9672a4b2f42adb1be04a5b1"} - ]); + ], promise); assert.ok(collection.get('1')); assert.ok(collection.get('3')); assert.notOk(collection.get('2')); }); + + it('resolves promise on successful delete', function () { + var promise = FauxtonAPI.Deferred(); + var spy = sinon.spy(); + + promise.then(spy); + + collection.handleResponse([ + {"ok":true,"id":"1","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, + {"ok":true,"id":"2","rev":"6-da537822b9672a4b2f42adb1be04a5b1"} + ], promise); + + assert.ok(spy.calledOnce); + }); + + it('resolves promise with list of errored ids', function () { + var promise = FauxtonAPI.Deferred(); + var spy = sinon.spy(); + + promise.then(spy); + + collection.handleResponse([ + {"error":"confclict","id":"1","rev":"10-72cd2edbcc0d197ce96188a229a7af01"}, --- End diff -- And copy-pasted it here (:
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---