diff --git a/chrome/content/zotero/xpcom/collectionTreeView.js b/chrome/content/zotero/xpcom/collectionTreeView.js index 6976e4ade..143a02757 100644 --- a/chrome/content/zotero/xpcom/collectionTreeView.js +++ b/chrome/content/zotero/xpcom/collectionTreeView.js @@ -1181,9 +1181,7 @@ Zotero.CollectionTreeView.prototype.deleteSelection = Zotero.Promise.coroutine(f //erase collection from DB: var treeRow = this.getRow(rows[i]-i); if (treeRow.isCollection() || treeRow.isFeed()) { - yield treeRow.ref.eraseTx({ - deleteItems: true - }); + yield treeRow.ref.eraseTx({ deleteItems }); if (treeRow.isFeed()) { refreshFeeds = true; } diff --git a/test/tests/zoteroPaneTest.js b/test/tests/zoteroPaneTest.js index ff1cd084f..f7c47eb3e 100644 --- a/test/tests/zoteroPaneTest.js +++ b/test/tests/zoteroPaneTest.js @@ -230,6 +230,28 @@ describe("ZoteroPane", function() { }) }) + describe("#deleteSelectedCollection()", function () { + it("should delete collection but not descendant items by default", function* () { + var collection = yield createDataObject('collection'); + var item = yield createDataObject('item', { collections: [collection.id] }); + var promise = waitForDialog(); + yield zp.deleteSelectedCollection(); + assert.isFalse(Zotero.Collections.exists(collection.id)); + assert.isTrue(Zotero.Items.exists(item.id)); + assert.isFalse(item.deleted); + }); + + it("should delete collection and descendant items when deleteItems=true", function* () { + var collection = yield createDataObject('collection'); + var item = yield createDataObject('item', { collections: [collection.id] }); + var promise = waitForDialog(); + yield zp.deleteSelectedCollection(true); + assert.isFalse(Zotero.Collections.exists(collection.id)); + assert.isTrue(Zotero.Items.exists(item.id)); + assert.isTrue(item.deleted); + }); + }); + describe("#setVirtual()", function () { var cv;