www

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

libraryTreeViewTest.js (1285B)


      1 "use strict";
      2 
      3 describe("Zotero.LibraryTreeView", function() {
      4 	var win, zp, cv, itemsView;
      5 	
      6 	// Load Zotero pane and select library
      7 	before(function* () {
      8 		win = yield loadZoteroPane();
      9 		zp = win.ZoteroPane;
     10 		cv = zp.collectionsView;
     11 	});
     12 	beforeEach(function* () {
     13 		yield selectLibrary(win);
     14 		itemsView = zp.itemsView;
     15 	})
     16 	after(function () {
     17 		win.close();
     18 	});
     19 	
     20 	describe("#getRowIndexByID()", function () {
     21 		it("should return the row index of an item", function* () {
     22 			var collection = yield createDataObject('collection');
     23 			yield waitForItemsLoad(win);
     24 			var item = yield createDataObject('item', { collections: [collection.id] });
     25 			var view = zp.itemsView;
     26 			assert.strictEqual(view.getRowIndexByID(item.treeViewID), 0);
     27 		});
     28 	});
     29 	
     30 	describe("#_removeRow()", function () {
     31 		it("should remove the last row", function* () {
     32 			var collection = yield createDataObject('collection');
     33 			yield waitForItemsLoad(win);
     34 			yield createDataObject('item', { collections: [collection.id] });
     35 			yield createDataObject('item', { collections: [collection.id] });
     36 			
     37 			var view = zp.itemsView;
     38 			var treeViewID = view.getRow(1).id;
     39 			zp.itemsView._removeRow(1);
     40 			
     41 			assert.equal(view.rowCount, 1);
     42 			assert.isFalse(view.getRowIndexByID(treeViewID));
     43 		});
     44 	});
     45 })