mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
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:
co-authored by
grzdev
Eric Fennis
parent
8857d7a636
commit
c0c8de1db2
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user