Add test for numDistinctFileAttachmentsForLabel() filter function

This commit is contained in:
Dan Stillman 2024-05-19 00:50:43 -04:00 committed by Dan Stillman
parent 90634fc5c8
commit 47bf4de08a

View file

@ -1361,6 +1361,17 @@ describe("Zotero.Items", function () {
await zp.selectItems([item1.id, attachment1.id, attachment2.id]); await zp.selectItems([item1.id, attachment1.id, attachment2.id]);
assert.equal(getNum(), 2); 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 () { describe("#_loadChildItems()", function () {