mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-12 13:38:32 +00:00
* feat(packages): added lucide icons package skeleton
* feat(packages): added initial commit of @lucide/icons
* fix: fixed linting issues introduced in c4e5730bc4 (#3858)
* fix(packages/icons): update package, remove UMD export
* fix(packages/icons): update github actions
* docs(packages/icons): add documentation for various helpers and types
* fix(.github/ISSUE_TEMPLATE): fix linting issue (@ is a reserved character)
* fix(packages/icons): fix linting issues in configs
* feat(packages/icons): rename from packages/lucide-icons => packages/icons
* fix(pnpm): update lockfile
* fix(packages/icons): update readme and documentation
* fix(packages/icons): update absoluteStrokeWidth implementation
* test(packages/icons): update absoluteStrokeWidth unit test
* feat(packages/icons): add backwards compatible alias support in buildLucideIconNode
* feat(packages/icons): fix linting issues in build tools
* fix(packages/icons): rename LucideIcon => LucideIconData
---------
Co-authored-by: Eric Fennis <eric.fennis@gmail.com>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { House } from '../src/lucide-icons';
|
|
import { getOriginalSvg, removeKeys } from './helpers';
|
|
import buildLucideIconElement from '../src/buildLucideIconElement';
|
|
|
|
describe('buildLucideIconElement', () => {
|
|
it('should create SVG Element', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House);
|
|
|
|
expect(HomeSVG.tagName).toBe('svg');
|
|
});
|
|
|
|
it('should match the snapshot', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House);
|
|
|
|
expect(HomeSVG.outerHTML).toMatchSnapshot();
|
|
});
|
|
|
|
it('should create SVG Element with attributes', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House, { attributes: { fill: 'red' } });
|
|
|
|
expect(HomeSVG.getAttribute('fill')).toBe('red');
|
|
});
|
|
|
|
it('should create SVG Element with class name', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House, { attributes: { class: 'icon' } });
|
|
|
|
expect(HomeSVG.getAttribute('class')).toBe('icon');
|
|
});
|
|
|
|
it('should add backwards-compatible classes', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House);
|
|
|
|
expect(HomeSVG.getAttribute('class')).toBe('lucide lucide-house lucide-home');
|
|
});
|
|
|
|
it('should merge classes', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House, { className: 'icon' });
|
|
|
|
expect(HomeSVG.getAttribute('class')).toBe('lucide lucide-house lucide-home icon');
|
|
});
|
|
|
|
it('should create the correct svg element', () => {
|
|
const HomeSVG = buildLucideIconElement(document, House);
|
|
|
|
const svg = getOriginalSvg('house', ['home']);
|
|
|
|
expect(removeKeys(HomeSVG.outerHTML)).toBe(svg);
|
|
});
|
|
});
|