Generalize Zotero.CachedTypes.add(), and tweak item charset handling

.attachmentCharset on an item now requires a string, not a charsetID.
(It accepted a charset before but didn't quite work right.)
This commit is contained in:
Dan Stillman 2015-06-01 19:52:17 -04:00
parent bf0d2a1bf4
commit 5fc524bcb2
4 changed files with 98 additions and 61 deletions

View file

@ -423,10 +423,24 @@ describe("Zotero.Item", function () {
item.attachmentLinkMode = Zotero.Attachments.LINK_MODE_IMPORTED_FILE;
item.attachmentCharset = charset;
var itemID = yield item.saveTx();
assert.equal(item.attachmentCharset, charset);
item = yield Zotero.Items.getAsync(itemID);
assert.equal(item.attachmentCharset, charset);
})
it("should not allow a numerical value", function* () {
var charset = 1;
var item = new Zotero.Item("attachment");
try {
item.attachmentCharset = charset;
}
catch (e) {
assert.equal(e.message, "Character set must be a string")
return;
}
assert.fail("Numerical charset was allowed");
})
it("should not be marked as changed if not changed", function* () {
var charset = 'utf-8';
var item = new Zotero.Item("attachment");