2024-07-25 20:04:08 +00:00
|
|
|
import { describe, test, expect } from 'vitest';
|
2021-04-30 09:51:31 +00:00
|
|
|
import { render } from '@testing-library/svelte';
|
2024-04-15 15:15:11 +00:00
|
|
|
import Icon from '../../offline';
|
2021-04-30 09:51:31 +00:00
|
|
|
|
|
|
|
const iconData = {
|
2021-05-14 18:39:12 +00:00
|
|
|
body: '<path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"/>',
|
2021-04-30 09:51:31 +00:00
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Dimensions', () => {
|
|
|
|
test('height', () => {
|
|
|
|
const component = render(Icon, { icon: iconData, height: '48' });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
|
|
|
expect(node.getAttribute('height')).toBe('48');
|
|
|
|
expect(node.getAttribute('width')).toBe('48');
|
2021-04-30 09:51:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('width and height', () => {
|
|
|
|
const component = render(Icon, {
|
|
|
|
icon: iconData,
|
|
|
|
// Mixing numbers and strings
|
|
|
|
width: 32,
|
|
|
|
height: '48',
|
|
|
|
});
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
|
|
|
expect(node.getAttribute('height')).toBe('48');
|
|
|
|
expect(node.getAttribute('width')).toBe('32');
|
2021-04-30 09:51:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('auto', () => {
|
|
|
|
const component = render(Icon, {
|
|
|
|
icon: iconData,
|
|
|
|
height: 'auto',
|
|
|
|
});
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
|
|
|
expect(node.getAttribute('height')).toBe('24');
|
|
|
|
expect(node.getAttribute('width')).toBe('24');
|
2021-04-30 09:51:31 +00:00
|
|
|
});
|
2023-01-27 17:52:22 +00:00
|
|
|
|
|
|
|
test('none', () => {
|
|
|
|
const component = render(Icon, {
|
|
|
|
icon: iconData,
|
|
|
|
height: 'none',
|
|
|
|
});
|
|
|
|
const node = component.container.querySelector('svg')!;
|
|
|
|
expect(node.getAttribute('height')).toBe(null);
|
|
|
|
expect(node.getAttribute('width')).toBe(null);
|
|
|
|
});
|
2021-04-30 09:51:31 +00:00
|
|
|
});
|