Update utilities submodule

And add tests for `Utilities.Internal.noteToTitle()`

Follow-up to zotero/utilities@df2dda23b
This commit is contained in:
Dan Stillman 2022-02-18 15:11:25 -05:00
parent 5405da99db
commit 5eee488e20
2 changed files with 22 additions and 1 deletions

@ -1 +1 @@
Subproject commit 9390fa2a4fd749688f2cf78e8a62a716643f4b90
Subproject commit df2dda23b7787215762d41fc654a8ab7fb99056a

View file

@ -258,4 +258,25 @@ describe("Zotero.Utilities.Item", function() {
assert.equal(accessed['date-parts'][0][2], 9);
});
});
describe("#noteToTitle()", function () {
it("should stop after first block element with content", async function () {
var str = "<h1>Foo</h1><p>Bar</p>";
var title = Zotero.Utilities.Item.noteToTitle(str, { stopAtLineBreak: true });
assert.equal(title, 'Foo');
});
it("should skip first line if no content", async function () {
var str = "<blockquote>\n<p>Foo</p>\n</blockquote>\n<p>Bar</p>";
var title = Zotero.Utilities.Item.noteToTitle(str);
assert.equal(title, 'Foo');
});
it("should stop at <br/> when options.stopAtLineBreak is true", async function () {
var str = "<h1>Annotations<br/>(2/18/2022, 3:49:43 AM)</h1><p>Foo</p>";
var title = Zotero.Utilities.Item.noteToTitle(str, { stopAtLineBreak: true });
assert.equal(title, 'Annotations');
});
});
});