backbone-dnode
backbone-dnode copied to clipboard
tests failing for "should delete the record"
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)) }
Good catch, I'll add the change as soon as I can, unless you are wanting to make a pull request.