test(lucide): add tests for empty icons error and DocumentFragment root in createIcons (#4967)

Co-authored-by: grzdev <grzdev@users.noreply.github.com>
Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
This commit is contained in:
Dami Oyeniyi
2026-10-09 13:18:12 +02:00
committed by GitHub
co-authored by grzdev Eric Fennis
parent 8857d7a636
commit c0c8de1db2
+16
View File
@@ -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();
});
});