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>
93 lines
2.9 KiB
TypeScript
93 lines
2.9 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { House } from '../src/lucide-icons';
|
|
import buildLucideIconNode from '../src/buildLucideIconNode';
|
|
|
|
describe('buildLucideIconNode', () => {
|
|
it('should create icon node', () => {
|
|
const HouseSVG = buildLucideIconNode(House);
|
|
|
|
expect(HouseSVG.at(0)).toBe('svg');
|
|
});
|
|
|
|
it('should match the snapshot', () => {
|
|
const HouseSVG = buildLucideIconNode(House);
|
|
|
|
expect(JSON.stringify(HouseSVG.at(1))).toMatchSnapshot();
|
|
});
|
|
|
|
it('should override dimensions, but not viewBox', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { size: 12 });
|
|
|
|
expect(HouseSVG[1]['width']).toBe('12');
|
|
expect(HouseSVG[1]['height']).toBe('12');
|
|
expect(HouseSVG[1]['viewBox']).toBe('0 0 24 24');
|
|
});
|
|
|
|
it('should override width, but not height', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { width: 12 });
|
|
|
|
expect(HouseSVG[1]['width']).toBe('12');
|
|
expect(HouseSVG[1]['height']).toBe('24');
|
|
expect(HouseSVG[1]['viewBox']).toBe('0 0 24 24');
|
|
});
|
|
|
|
it('should override height, but not width', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { height: 12 });
|
|
|
|
expect(HouseSVG[1]['width']).toBe('24');
|
|
expect(HouseSVG[1]['height']).toBe('12');
|
|
expect(HouseSVG[1]['viewBox']).toBe('0 0 24 24');
|
|
});
|
|
|
|
it('should override color', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { color: 'pink' });
|
|
|
|
expect(HouseSVG[1]['stroke']).toBe('pink');
|
|
expect(HouseSVG[1]['fill']).toBe('none');
|
|
});
|
|
|
|
it('should override stroke width', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { strokeWidth: 12 });
|
|
|
|
expect(HouseSVG[1]['stroke-width']).toBe('12');
|
|
});
|
|
|
|
it('should set non-scaling-stroke to child nodes', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { absoluteStrokeWidth: true });
|
|
|
|
for (const node of HouseSVG[2]!) {
|
|
expect(node[1]['vector-effect']).toBe('non-scaling-stroke');
|
|
}
|
|
});
|
|
|
|
it('should not set non-scaling-stroke', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { absoluteStrokeWidth: false });
|
|
|
|
expect(HouseSVG[1]['vector-effect']).toBeUndefined();
|
|
});
|
|
|
|
it('should create icon node with attributes', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { attributes: { fill: 'red' } });
|
|
|
|
expect(HouseSVG[1]['fill']).toBe('red');
|
|
});
|
|
|
|
it('should create icon node with class name', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { attributes: { class: 'icon' } });
|
|
|
|
expect(HouseSVG[1]['class']).toBe('icon');
|
|
});
|
|
|
|
it('should add backwards-compatible classes', () => {
|
|
const HouseSVG = buildLucideIconNode(House);
|
|
|
|
expect(HouseSVG[1]['class']).toBe('lucide lucide-house lucide-home');
|
|
});
|
|
|
|
it('should merge classes', () => {
|
|
const HouseSVG = buildLucideIconNode(House, { className: 'icon' });
|
|
|
|
expect(HouseSVG[1]['class']).toBe('lucide lucide-house lucide-home icon');
|
|
});
|
|
});
|