Add Zotero.URI.getURIItemLibraryKeyFromDB()
Allows getting libraryID and key without relying on library data being loaded (e.g., at startup)
This commit is contained in:
parent
5873e554f1
commit
90a27f8d4b
2 changed files with 129 additions and 0 deletions
37
test/tests/uriTest.js
Normal file
37
test/tests/uriTest.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
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);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue