www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 56e40c485ba8a5e0d019f27ebe414685c8e762aa
parent 8b4a5936a38cadf15dbca9ae681f61d345226b0f
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 20 May 2016 23:42:07 -0400

A couple libraryTreeView tests

Diffstat:
Atest/tests/libraryTreeViewTest.js | 45+++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+), 0 deletions(-)

diff --git a/test/tests/libraryTreeViewTest.js b/test/tests/libraryTreeViewTest.js @@ -0,0 +1,45 @@ +"use strict"; + +describe("Zotero.LibraryTreeView", function() { + var win, zp, cv, itemsView; + + // Load Zotero pane and select library + before(function* () { + win = yield loadZoteroPane(); + zp = win.ZoteroPane; + cv = zp.collectionsView; + }); + beforeEach(function* () { + yield selectLibrary(win); + itemsView = zp.itemsView; + }) + after(function () { + win.close(); + }); + + describe("#getRowIndexByID()", function () { + it("should return the row index of an item", function* () { + var collection = yield createDataObject('collection'); + yield waitForItemsLoad(win); + var item = yield createDataObject('item', { collections: [collection.id] }); + var view = zp.itemsView; + assert.strictEqual(view.getRowIndexByID(item.treeViewID), 0); + }); + }); + + describe("#_removeRow()", function () { + it("should remove the last row", function* () { + var collection = yield createDataObject('collection'); + yield waitForItemsLoad(win); + var item1 = yield createDataObject('item', { collections: [collection.id] }); + var item2 = yield createDataObject('item', { collections: [collection.id] }); + + var view = zp.itemsView; + assert.equal(view.getRowIndexByID(item2.id), 1); + zp.itemsView._removeRow(1); + + assert.equal(view.rowCount, 1); + assert.isFalse(view.getRowIndexByID(item2.id)); + }); + }); +})