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]);
|
2021-01-21 03:32:56 +00:00
|
|
|
assert.match(item.getField("title"), /^Zotero: a guide for librarians, researchers/);
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|
|
|
|
});
|
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]);
|
2021-01-21 03:32:56 +00:00
|
|
|
assert.match(item.getField("title"), /^Zotero: a guide for librarians, researchers/);
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|
|
|
|
});
|
2016-04-24 08:28:56 +00:00
|
|
|
|
2015-03-08 22:39:42 +00:00
|
|
|
it("should add a DOI", function() {
|
2021-01-18 09:14:36 +00:00
|
|
|
this.timeout(20000);
|
2015-03-08 22:39:42 +00:00
|
|
|
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
|
|
|
|
2018-06-16 18:34:29 +00:00
|
|
|
it.skip("should add a DOI with an open-access PDF");
|
|
|
|
|
|
|
|
// e.g., arXiv
|
|
|
|
it.skip("should not add a PDF if a DOI already retrieves one");
|
|
|
|
|
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* () {
|
2021-01-18 09:14:36 +00:00
|
|
|
this.timeout(20000);
|
2016-04-24 08:28:56 +00:00
|
|
|
|
|
|
|
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]);
|
2018-06-27 14:28:38 +00:00
|
|
|
assert.equal(item.getField("title"), "Comparison Of Spectral Methods Through The Adjacency Matrix And The Laplacian Of A Graph");
|
2016-06-11 18:54:06 +00:00
|
|
|
assert.isTrue(item.inCollection(col.id));
|
2016-04-24 08:28:56 +00:00
|
|
|
});
|
2015-03-08 22:39:42 +00:00
|
|
|
});
|