2016-05-21 03:42:07 +00:00
|
|
|
"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);
|
2016-07-20 00:31:06 +00:00
|
|
|
yield createDataObject('item', { collections: [collection.id] });
|
|
|
|
yield createDataObject('item', { collections: [collection.id] });
|
2016-05-21 03:42:07 +00:00
|
|
|
|
|
|
|
var view = zp.itemsView;
|
2016-07-20 00:31:06 +00:00
|
|
|
var treeViewID = view.getRow(1).id;
|
2016-05-21 03:42:07 +00:00
|
|
|
zp.itemsView._removeRow(1);
|
|
|
|
|
|
|
|
assert.equal(view.rowCount, 1);
|
2016-07-20 00:31:06 +00:00
|
|
|
assert.isFalse(view.getRowIndexByID(treeViewID));
|
2016-05-21 03:42:07 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|