From 5eee488e206930ce734a2da504eed65c69a289c1 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 18 Feb 2022 15:11:25 -0500 Subject: [PATCH] Update utilities submodule And add tests for `Utilities.Internal.noteToTitle()` Follow-up to zotero/utilities@df2dda23b --- chrome/content/zotero/xpcom/utilities | 2 +- test/tests/utilities_itemTest.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/utilities b/chrome/content/zotero/xpcom/utilities index 9390fa2a4f..df2dda23b7 160000 --- a/chrome/content/zotero/xpcom/utilities +++ b/chrome/content/zotero/xpcom/utilities @@ -1 +1 @@ -Subproject commit 9390fa2a4fd749688f2cf78e8a62a716643f4b90 +Subproject commit df2dda23b7787215762d41fc654a8ab7fb99056a diff --git a/test/tests/utilities_itemTest.js b/test/tests/utilities_itemTest.js index 158f396aba..6e48cd5cdc 100644 --- a/test/tests/utilities_itemTest.js +++ b/test/tests/utilities_itemTest.js @@ -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 = "

Foo

Bar

"; + 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 = "
\n

Foo

\n
\n

Bar

"; + var title = Zotero.Utilities.Item.noteToTitle(str); + assert.equal(title, 'Foo'); + }); + + it("should stop at
when options.stopAtLineBreak is true", async function () { + var str = "

Annotations
(2/18/2022, 3:49:43 AM)

Foo

"; + var title = Zotero.Utilities.Item.noteToTitle(str, { stopAtLineBreak: true }); + assert.equal(title, 'Annotations'); + }); + }); });