zotero/test/tests/zoteroPaneTest.js

38 lines
1.2 KiB
JavaScript
Raw Normal View History

describe("ZoteroPane", function() {
var win, doc, zp;
// Load Zotero pane and select library
before(function* () {
win = yield loadZoteroPane();
doc = win.document;
zp = win.ZoteroPane;
});
after(function () {
win.close();
});
describe("#newItem", function () {
it("should create an item and focus the title field", function* () {
yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true);
var itemBox = doc.getElementById('zotero-editpane-item-box');
var textboxes = doc.getAnonymousNodes(itemBox)[0].getElementsByTagName('textbox');
assert.lengthOf(textboxes, 1);
assert.equal(textboxes[0].getAttribute('fieldname'), 'title');
textboxes[0].blur();
yield Zotero.Promise.delay(1);
})
it("should save an entered value when New Item is used", function* () {
var value = "Test";
var item = yield zp.newItem(Zotero.ItemTypes.getID('book'), {}, null, true);
var itemBox = doc.getElementById('zotero-editpane-item-box');
var textbox = doc.getAnonymousNodes(itemBox)[0].getElementsByTagName('textbox')[0];
textbox.value = value;
yield itemBox.blurOpenField();
item = yield Zotero.Items.getAsync(item.id);
assert.equal(item.getField('title'), value);
})
});
})