www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

lookupTest.js (2539B)


      1 var lookupIdentifier = Zotero.Promise.coroutine(function* (win, identifier) {
      2 	var textbox = win.document.getElementById("zotero-lookup-textbox");
      3 	textbox.value = identifier;
      4 	var promise = waitForItemEvent("add");
      5 	yield win.Zotero_Lookup.accept(textbox);
      6 	return promise;
      7 });
      8 
      9 describe("Add Item by Identifier", function() {
     10 	var win;
     11 	
     12 	before(function* () {
     13 		if (Zotero.automatedTest) {
     14 			this.skip();
     15 			return;
     16 		}
     17 		win = yield loadZoteroPane();
     18 	});
     19 	
     20 	after(function() {
     21 		if (win) {
     22 			win.close();
     23 		}
     24 	});
     25 	
     26 	// TODO: mock external services: https://github.com/zotero/zotero/issues/699
     27 	
     28 	it("should add an ISBN-10", function() {
     29 		this.timeout(20000);
     30 		return lookupIdentifier(win, "0838985890").then(function(ids) {
     31 			var item = Zotero.Items.get(ids[0]);
     32 			assert.equal(item.getField("title"), "Zotero: a guide for librarians, researchers, and educators");
     33 		});
     34 	});
     35 	
     36 	it("should add an ISBN-13", function() {
     37 		this.timeout(20000);
     38 		return lookupIdentifier(win, "978-0838985892").then(function(ids) {
     39 			var item = Zotero.Items.get(ids[0]);
     40 			assert.equal(item.getField("title"), "Zotero: a guide for librarians, researchers, and educators");
     41 		});
     42 	});
     43 	
     44 	it("should add a DOI", function() {
     45 		this.timeout(10000);
     46 		return lookupIdentifier(win, "10.4103/0976-500X.85940").then(function(ids) {
     47 			var item = Zotero.Items.get(ids[0]);
     48 			assert.equal(item.getField("title"), "Zotero: A bibliographic assistant to researcher");
     49 		});
     50 	});
     51 	
     52 	it("should add a PMID", function() {
     53 		this.timeout(10000);
     54 		return lookupIdentifier(win, "24297125").then(function(ids) {
     55 			var item = Zotero.Items.get(ids[0]);
     56 			assert.equal(item.getField("title"), "Taking control of your digital library: how modern citation managers do more than just referencing");
     57 		});
     58 	});
     59 	
     60 	it("should add an item within a collection", function* () {
     61 		this.timeout(10000);
     62 		
     63 		var col = yield createDataObject('collection');
     64 		yield waitForItemsLoad(win);
     65 		
     66 		// Initial translator
     67 		var ids = yield lookupIdentifier(win, "10.4103/0976-500X.85940");
     68 		var item = Zotero.Items.get(ids[0]);
     69 		assert.equal(item.getField("title"), "Zotero: A bibliographic assistant to researcher");
     70 		assert.isTrue(item.inCollection(col.id));
     71 		
     72 		// Fallback translator
     73 		var ids = yield lookupIdentifier(win, "10.5281/zenodo.55073");
     74 		var item = Zotero.Items.get(ids[0]);
     75 		assert.equal(item.getField("title"), "Comparison of Spectral Methods Through the Adjacency Matrix and the Laplacian of a Graph");
     76 		assert.isTrue(item.inCollection(col.id));
     77 	});
     78 });