2016-12-13 10:23:21 +00:00
|
|
|
var lookupIdentifier = Zotero.Promise.coroutine(function* (win, identifier) {
|
2015-03-09 18:39:04 +00:00
|
|
|
var textbox = win.document.getElementById("zotero-lookup-textbox");
|
|
|
|
textbox.value = identifier;
|
2016-12-13 10:23:21 +00:00
|
|
|
var promise = waitForItemEvent("add");
|
|
|
|
yield win.Zotero_Lookup.accept(textbox);
|
|
|
|
return promise;
|
|
|
|
});
|
2015-03-08 22:39:42 +00:00
|
|
|
|
2016-12-13 10:23:21 +00:00
|
|
|
describe("Add Item by Identifier", function() {
|
2015-03-08 22:39:42 +00:00
|
|
|
var win;
|
2016-04-24 08:28:56 +00:00
|
|
|
|
|
|
|
before(function* () {
|
2016-12-13 10:23:21 +00:00
|
|
|
if (Zotero.automatedTest) {
|
|
|
|
this.skip();
|
|
|
|
return;
|
|
|
|
}
|
2016-04-24 08:28:56 +00:00
|
|
|
win = yield loadZoteroPane();
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
after(function() {
|
2016-12-13 10:23:21 +00:00
|
|
|
if (win) {
|
|
|
|
win.close();
|
|
|
|
}
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
|
|
|
// TODO: mock external services: https://github.com/zotero/zotero/issues/699
|
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
it("should add an ISBN-10", function() {
|
2015-03-11 18:35:55 +00:00
|
|
|
this.timeout(20000);
|
2015-03-08 22:39:42 +00:00
|
|
|
return lookupIdentifier(win, "0838985890").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Zotero: a guide for librarians, researchers, and educators");
|
|
|
|
});
|
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
it("should add an ISBN-13", function() {
|
2015-03-11 18:35:55 +00:00
|
|
|
this.timeout(20000);
|
2015-03-08 22:39:42 +00:00
|
|
|
return lookupIdentifier(win, "978-0838985892").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Zotero: a guide for librarians, researchers, and educators");
|
|
|
|
});
|
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
it("should add a DOI", function() {
|
|
|
|
this.timeout(10000);
|
|
|
|
return lookupIdentifier(win, "10.4103/0976-500X.85940").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Zotero: A bibliographic assistant to researcher");
|
|
|
|
});
|
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
it("should add a PMID", function() {
|
|
|
|
this.timeout(10000);
|
|
|
|
return lookupIdentifier(win, "24297125").then(function(ids) {
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Taking control of your digital library: how modern citation managers do more than just referencing");
|
|
|
|
});
|
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
|
|
|
it("should add an item within a collection", function* () {
|
|
|
|
this.timeout(10000);
|
|
|
|
|
|
|
|
var col = yield createDataObject('collection');
|
|
|
|
yield waitForItemsLoad(win);
|
|
|
|
|
2016-06-11 18:54:06 +00:00
|
|
|
// Initial translator
|
2016-04-24 08:28:56 +00:00
|
|
|
var ids = yield lookupIdentifier(win, "10.4103/0976-500X.85940");
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Zotero: A bibliographic assistant to researcher");
|
|
|
|
assert.isTrue(item.inCollection(col.id));
|
2016-06-11 18:54:06 +00:00
|
|
|
|
|
|
|
// Fallback translator
|
|
|
|
var ids = yield lookupIdentifier(win, "10.5281/zenodo.55073");
|
|
|
|
var item = Zotero.Items.get(ids[0]);
|
|
|
|
assert.equal(item.getField("title"), "Comparison of Spectral Methods Through the Adjacency Matrix and the Laplacian of a Graph");
|
|
|
|
assert.isTrue(item.inCollection(col.id));
|
2016-04-24 08:28:56 +00:00
|
|
|
});
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|