Add 'archived' property to Zotero.Library objects

Set when a user loses access to a library but chooses to keep it as a
read-only library.
This commit is contained in:
Dan Stillman 2017-02-24 00:13:11 -05:00
parent 88184b341b
commit 9ac458e05c
5 changed files with 53 additions and 4 deletions

View file

@ -127,6 +127,37 @@ describe("Zotero.Library", function() {
});
});
describe("#archived", function() {
it("should return archived status", function() {
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
assert.isFalse(library.archived, 'user library is not archived');
});
it("should allow setting archived status", function* () {
let library = yield createGroup({ editable: false, archived: true });
assert.isTrue(library.archived);
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT archived FROM libraries WHERE libraryID=?", library.libraryID)), 1)
library.archived = false;
yield library.saveTx();
assert.isFalse(library.archived);
assert.equal((yield Zotero.DB.valueQueryAsync("SELECT archived FROM libraries WHERE libraryID=?", library.libraryID)), 0)
});
it("should not be settable for user and publications libraries", function* () {
let library = Zotero.Libraries.get(Zotero.Libraries.userLibraryID);
assert.throws(() => library.archived = true, /^Cannot change _libraryArchived for user library$/, "does not allow setting user library as archived");
library = Zotero.Libraries.get(Zotero.Libraries.publicationsLibraryID);
assert.throws(() => library.archived = true, /^Cannot change _libraryArchived for publications library$/, "does not allow setting publications library as archived");
});
it("should only be settable on read-only library", function* () {
let library = yield createGroup();
assert.throws(() => library.archived = true, /^Cannot set editable library as archived$/);
});
});
describe("#save()", function() {
it("should require mandatory parameters to be set", function* () {
let library = new Zotero.Library({ editable: true, filesEditable: true });