Files
lucide/packages/lucide-svelte/tests/lucide-svelte.spec.ts
Eric Fennis fa6ed02297 Implement: Typescript, Esbuild and vitest (#877)
* init modernization

* implement esbuild

* Make first build work

* Fix esbuild for lucide-react

* Add vitest for lucide-react

* add esbuild lucide and lucide-react

* update package lock

* implement preact

* Add typescript and vitest

* adjust workflows

* Fix mocking react-native package

* update lock file

* Add esbuild in svelte

* make svelte test work in vitest

* Refactor lucide svelte

* Transform lucide vue to typescript

* Finish lucide-vue-next typescript

* 0.104.0-beta.0

* remove version in main package.json

* cleanup

* Fix svelte tests snapshots

* clean up

* add rollup lucide-vue-next

* Fix lucide svelte package

* change to workspace link

* revert filter position

* revert preact workflow change

* cleanup

* Fix some types

* add semi
2022-12-04 22:38:56 +01:00

58 lines
1.5 KiB
TypeScript

import { describe, it, expect, afterEach } from 'vitest';
import { render, cleanup } from '@testing-library/svelte';
import { Smile } from '../src/icons'
import TestSlots from './TestSlots.svelte'
describe('Using lucide icon components', () => {
afterEach(() => cleanup())
it('should render an component', () => {
const { container } = render(Smile);
expect(container).toMatchSnapshot();
});
it('should adjust the size, stroke color and stroke width', () => {
const { container } = render(Smile, {
props: {
size: 48,
color: 'red',
strokeWidth: 4
}
});
expect(container).toMatchSnapshot();
});
it('should add a class to the element', () => {
render(Smile, {
props: {
class: "my-icon"
}
});
const [icon] = document.getElementsByClassName('my-icon');
expect(icon).toBeInTheDocument();
expect(icon).toMatchSnapshot();
expect(icon.getAttribute("class")).toBe(['lucide-icon','lucide','lucide-smile', 'my-icon'].join(' '));
});
it('should add a style attribute to the element', () => {
render(Smile, {
props: {
style: "position: absolute;"
}
});
const [icon] = document.getElementsByClassName('lucide');
expect(icon.getAttribute('style')).toContain('position: absolute');
});
it('should render an icon slot', () => {
const { container, getByText } = render(TestSlots);
const textElement = getByText('Test');
expect(textElement).toBeInTheDocument();
expect(container).toMatchSnapshot();
});
});