import { describe, it, expect, afterEach } from 'vitest'; import { render, cleanup } from '@testing-library/svelte'; import { IconAccessible, IconAccessibleFilled } from './src/tabler-icons-svelte-runes.js'; describe('Svelte Runes Icon component', () => { afterEach(() => cleanup()); it('should render icon component', () => { const { container } = render(IconAccessible); expect(container.getElementsByTagName('svg').length).toBeGreaterThan(0); }); it('should add a class to the element', () => { const { container } = render(IconAccessible, { props: { class: 'test-class', }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg).toHaveClass('test-class'); expect(svg).toHaveClass('tabler-icon'); expect(svg).toHaveClass('tabler-icon-accessible'); }); it('should add a style attribute to the element', () => { const { container } = render(IconAccessible, { props: { style: 'color: red', }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg).toHaveStyle('color: rgb(255, 0, 0)'); }); it('should update svg attributes when there are props passed to the component', () => { const { container } = render(IconAccessible, { props: { size: 48, color: 'red', stroke: 4, }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg.getAttribute('width')).toBe('48'); expect(svg.getAttribute('stroke')).toBe('red'); expect(svg.getAttribute('stroke-width')).toBe('4'); }); it('should accept stroke as a number', () => { const { container } = render(IconAccessible, { props: { stroke: 3, }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg.getAttribute('stroke-width')).toBe('3'); }); it('should accept size as a string', () => { const { container } = render(IconAccessible, { props: { size: '100%', }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg.getAttribute('width')).toBe('100%'); expect(svg.getAttribute('height')).toBe('100%'); }); it('should update svg attributes when there are props passed to the filled version of component', () => { const { container } = render(IconAccessibleFilled, { props: { size: 48, color: 'red', }, }); const svg = container.getElementsByTagName('svg')[0]; expect(svg.getAttribute('width')).toBe('48'); expect(svg.getAttribute('fill')).toBe('red'); expect(svg.getAttribute('stroke')).toBe('none'); expect(svg.getAttribute('stroke-width')).toBe(null); }); it('should render children content using snippets', () => { const { container } = render(IconAccessible, { props: {}, // Test that children can be passed (even though we can't easily test snippet content in this setup) }); const svg = container.getElementsByTagName('svg')[0]; expect(svg).toBeDefined(); }); it('should match snapshot', () => { const { container } = render(IconAccessible); expect(container.innerHTML).toMatchInlineSnapshot(` `); }); });