2015-05-25 02:57:46 +00:00
|
|
|
describe("Zotero.Items", function () {
|
2015-05-25 05:43:07 +00:00
|
|
|
var win, collectionsView, zp;
|
2015-05-25 02:57:46 +00:00
|
|
|
|
|
|
|
before(function* () {
|
|
|
|
win = yield loadZoteroPane();
|
|
|
|
collectionsView = win.ZoteroPane.collectionsView;
|
2015-05-25 05:43:07 +00:00
|
|
|
zp = win.ZoteroPane;
|
2015-05-25 02:57:46 +00:00
|
|
|
})
|
|
|
|
beforeEach(function () {
|
|
|
|
return selectLibrary(win);
|
|
|
|
})
|
|
|
|
after(function () {
|
|
|
|
win.close();
|
|
|
|
})
|
|
|
|
|
|
|
|
describe("#emptyTrash()", function () {
|
|
|
|
it("should delete items in the trash", function* () {
|
|
|
|
var item1 = createUnsavedDataObject('item');
|
|
|
|
item1.setField('title', 'a');
|
|
|
|
item1.deleted = true;
|
|
|
|
var id1 = yield item1.saveTx();
|
|
|
|
|
|
|
|
var item2 = createUnsavedDataObject('item');
|
|
|
|
item2.setField('title', 'b');
|
|
|
|
item2.deleted = true;
|
|
|
|
var id2 = yield item2.saveTx();
|
|
|
|
|
|
|
|
var item3 = createUnsavedDataObject('item', { itemType: 'attachment', parentID: id2 });
|
|
|
|
item3.attachmentLinkMode = Zotero.Attachments.LINK_MODE_IMPORTED_URL;
|
|
|
|
item3.deleted = true;
|
|
|
|
var id3 = yield item3.saveTx();
|
|
|
|
|
|
|
|
yield collectionsView.selectTrash(Zotero.Libraries.userLibraryID);
|
|
|
|
|
|
|
|
yield Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID);
|
|
|
|
|
|
|
|
assert.isFalse(yield Zotero.Items.getAsync(id1));
|
|
|
|
assert.isFalse(yield Zotero.Items.getAsync(id2));
|
|
|
|
assert.isFalse(yield Zotero.Items.getAsync(id3));
|
2015-05-31 21:17:36 +00:00
|
|
|
|
|
|
|
// TEMP
|
|
|
|
// Should just be assert.equal(zp.itemsView.rowCount, 0), but it's failing on Travis
|
|
|
|
while (zp.itemsView.rowCount > 0) {
|
|
|
|
yield Zotero.Promise.delay(50);
|
|
|
|
}
|
2015-05-25 02:57:46 +00:00
|
|
|
})
|
|
|
|
})
|
2015-04-25 07:14:53 +00:00
|
|
|
});
|