Throw invalid-data error on unknown annotation type
This commit is contained in:
parent
40b871c2fd
commit
26bf507fe2
2 changed files with 18 additions and 1 deletions
|
@ -3683,7 +3683,9 @@ for (let name of ['type', 'text', 'comment', 'color', 'pageLabel', 'sortIndex',
|
|||
throw new Error("Cannot change annotation type");
|
||||
}
|
||||
if (!['highlight', 'note', 'image'].includes(value)) {
|
||||
throw new Error(`Invalid annotation type '${value}'`);
|
||||
let e = new Error(`Unknown annotation type '${value}'`);
|
||||
e.name = "ZoteroInvalidDataError";
|
||||
throw e;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1250,6 +1250,21 @@ describe("Zotero.Item", function () {
|
|||
attachment = await importFileAttachment('test.pdf', { parentID: item.id });
|
||||
});
|
||||
|
||||
describe("#annotationType", function () {
|
||||
it("should throw an invalid-data error if unknown type", function () {
|
||||
var a = new Zotero.Item('annotation');
|
||||
try {
|
||||
a.annotationType = 'foo';
|
||||
}
|
||||
catch (e) {
|
||||
assert.equal(e.name, 'ZoteroInvalidDataError');
|
||||
assert.equal(e.message, "Unknown annotation type 'foo'");
|
||||
return;
|
||||
}
|
||||
assert.fail("Invalid annotationType should throw");
|
||||
});
|
||||
});
|
||||
|
||||
describe("#annotationText", function () {
|
||||
it("should not be changeable", async function () {
|
||||
var a = new Zotero.Item('annotation');
|
||||
|
|
Loading…
Add table
Reference in a new issue