From c0c8de1db29c46a3cbb228584cece0cccb3ee95b Mon Sep 17 00:00:00 2001 From: Dami Oyeniyi Date: Fri, 9 Oct 2026 12:18:12 +0100 Subject: [PATCH] test(lucide): add tests for empty icons error and DocumentFragment root in createIcons (#4967) Co-authored-by: grzdev Co-authored-by: Eric Fennis --- packages/lucide/tests/lucide.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/lucide/tests/lucide.spec.ts b/packages/lucide/tests/lucide.spec.ts index e58dc9944..005e6ad96 100644 --- a/packages/lucide/tests/lucide.spec.ts +++ b/packages/lucide/tests/lucide.spec.ts @@ -126,4 +126,20 @@ describe('createIcons', () => { const hasIcon = !!document.querySelector('template')?.content.querySelector('svg'); expect(hasIcon).toBeTruthy(); }); + + it('should throw an error when icons object is empty', () => { + expect(() => createIcons({ icons: {} })).toThrowError(/Please provide an icons object/); + }); + + it('should replace icons within a DocumentFragment root', () => { + const fragment = document.createDocumentFragment(); + const iconEl = document.createElement('i'); + iconEl.setAttribute('data-lucide', 'volume-2'); + fragment.appendChild(iconEl); + + createIcons({ icons, root: fragment }); + + const hasSvg = !!fragment.querySelector('svg.lucide-volume-2'); + expect(hasSvg).toBeTruthy(); + }); });