zotero/test/tests/uriTest.js
Dan Stillman 90a27f8d4b Add Zotero.URI.getURIItemLibraryKeyFromDB()
Allows getting libraryID and key without relying on library data being
loaded (e.g., at startup)
2017-05-19 12:11:21 -04:00

37 lines
1.4 KiB
JavaScript

describe("Zotero.URI", function() {
describe("#getURIItemLibraryKeyFromDB()", function () {
it("should handle user library", function* () {
var key = 'ABCD2345';
var uri = `http://zotero.org/users/5/items/${key}`;
var obj = yield Zotero.URI.getURIItemLibraryKeyFromDB(uri);
assert.propertyVal(obj, 'libraryID', Zotero.Libraries.userLibraryID);
assert.propertyVal(obj, 'key', key);
});
it("should handle user library with local user key", function* () {
var key = 'ABCD2345';
var uri = `http://zotero.org/users/local/aaaaaaaa/items/${key}`;
var obj = yield Zotero.URI.getURIItemLibraryKeyFromDB(uri);
assert.propertyVal(obj, 'libraryID', Zotero.Libraries.userLibraryID);
assert.propertyVal(obj, 'key', key);
});
it("should handle publications URI", function* () {
var key = 'ABCD2345';
var uri = `http://zotero.org/users/5/publications/items/${key}`;
var obj = yield Zotero.URI.getURIItemLibraryKeyFromDB(uri);
assert.propertyVal(obj, 'libraryID', Zotero.Libraries.userLibraryID);
assert.propertyVal(obj, 'key', key);
});
it("should handle group URI", function* () {
var group = yield getGroup();
var key = 'ABCD2345';
var uri = `http://zotero.org/groups/${group.id}/items/${key}`;
var obj = yield Zotero.URI.getURIItemLibraryKeyFromDB(uri);
assert.propertyVal(obj, 'libraryID', group.libraryID);
assert.propertyVal(obj, 'key', key);
});
});
});