From 47bf4de08a9db172a936d6c8a409df999849e6bf Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 19 May 2024 00:50:43 -0400 Subject: [PATCH] Add test for `numDistinctFileAttachmentsForLabel()` filter function --- test/tests/itemsTest.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/tests/itemsTest.js b/test/tests/itemsTest.js index d6e4661f53..ccaf276518 100644 --- a/test/tests/itemsTest.js +++ b/test/tests/itemsTest.js @@ -1361,6 +1361,17 @@ describe("Zotero.Items", function () { await zp.selectItems([item1.id, attachment1.id, attachment2.id]); assert.equal(getNum(), 2); }); + + it("should return 0 for a parent item with a non-PDF attachment when passed `item.isPDFAttachment()` as a filter", async function () { + var item = await createDataObject('item'); + var attachment = await importFileAttachment('test.png', { parentItemID: item.id }); + + var numFiles = Zotero.Items.numDistinctFileAttachmentsForLabel( + [item], + item => item.isPDFAttachment() + ); + assert.equal(numFiles, 0); + }); }); describe("#_loadChildItems()", function () {