backbone-dnode icon indicating copy to clipboard operation
backbone-dnode copied to clipboard

tests failing for "should delete the record"

Open chrisfarms opened this issue 12 years ago • 1 comments

when a model is deleted from the collection it affects 'each' so the second Fruit is never destroyed. Could be argued that this is a bug in backbone, but a simple fix for the test is to copy the array first:

diff --git a/test/crud.test.js b/test/crud.test.js
index 2e0f6e7..96748ee 100644
--- a/test/crud.test.js
+++ b/test/crud.test.js
@@ -148,7 +148,7 @@ describe('CRUD', function() {
       if (x === l) return done()
     }

-    fruits.each(function(model) {
+    fruits.toArray().forEach(function(model) {
       model.destroy({
         finished: finished
       , error: function(model, resp) { done(new Error(resp)) }

chrisfarms avatar Apr 13 '12 13:04 chrisfarms

Good catch, I'll add the change as soon as I can, unless you are wanting to make a pull request.

sorensen avatar Apr 13 '12 16:04 sorensen