Get selected item ids directly in collection tests

This commit is contained in:
Dan Stillman 2015-05-05 02:40:01 -04:00
parent 09f08d63ea
commit 2313c1930d

View file

@ -20,13 +20,13 @@ describe("Zotero.ItemTreeView", function() {
*/ */
it("should return if item is already selected", function* () { it("should return if item is already selected", function* () {
yield itemsView.selectItem(existingItemID); yield itemsView.selectItem(existingItemID);
var selected = itemsView.getSelectedItems(); var selected = itemsView.getSelectedItems(true);
assert.lengthOf(selected, 1); assert.lengthOf(selected, 1);
assert.equal(selected[0].id, existingItemID); assert.equal(selected[0], existingItemID);
yield itemsView.selectItem(existingItemID); yield itemsView.selectItem(existingItemID);
selected = itemsView.getSelectedItems(); selected = itemsView.getSelectedItems(true);
assert.lengthOf(selected, 1); assert.lengthOf(selected, 1);
assert.equal(selected[0].id, existingItemID); assert.equal(selected[0], existingItemID);
}); });
}) })
@ -48,9 +48,9 @@ describe("Zotero.ItemTreeView", function() {
it("shouldn't select a new item if skipNotifier is passed", function* () { it("shouldn't select a new item if skipNotifier is passed", function* () {
// Select existing item // Select existing item
yield itemsView.selectItem(existingItemID); yield itemsView.selectItem(existingItemID);
var selected = itemsView.getSelectedItems(); var selected = itemsView.getSelectedItems(true);
assert.lengthOf(selected, 1); assert.lengthOf(selected, 1);
assert.equal(selected[0].id, existingItemID); assert.equal(selected[0], existingItemID);
// Create item with skipNotifier flag // Create item with skipNotifier flag
var item = new Zotero.Item('book'); var item = new Zotero.Item('book');
@ -59,17 +59,17 @@ describe("Zotero.ItemTreeView", function() {
}); });
// Existing item should still be selected // Existing item should still be selected
selected = itemsView.getSelectedItems(); selected = itemsView.getSelectedItems(true);
assert.lengthOf(selected, 1); assert.lengthOf(selected, 1);
assert.equal(selected[0].id, existingItemID); assert.equal(selected[0], existingItemID);
}); });
it("shouldn't select a new item if skipSelect is passed", function* () { it("shouldn't select a new item if skipSelect is passed", function* () {
// Select existing item // Select existing item
yield itemsView.selectItem(existingItemID); yield itemsView.selectItem(existingItemID);
var selected = itemsView.getSelectedItems(); var selected = itemsView.getSelectedItems(true);
assert.lengthOf(selected, 1); assert.lengthOf(selected, 1);
assert.equal(selected[0].id, existingItemID); assert.equal(selected[0], existingItemID);
// Create item with skipSelect flag // Create item with skipSelect flag
var item = new Zotero.Item('book'); var item = new Zotero.Item('book');