2021-09-27 13:29:45 +00:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
2021-04-30 09:51:31 +00:00
|
|
|
import { render } from '@testing-library/svelte';
|
2021-09-27 13:29:45 +00:00
|
|
|
|
|
|
|
// Test importing from exports
|
|
|
|
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('Creating component', () => {
|
|
|
|
test('basic icon', () => {
|
|
|
|
const component = render(Icon, { icon: iconData });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
|
|
|
const html = (node.parentNode as HTMLDivElement).innerHTML;
|
2021-04-30 09:51:31 +00:00
|
|
|
|
|
|
|
// Check HTML
|
2022-09-07 19:04:34 +00:00
|
|
|
expect(html.replace(/<!--(.*?)-->/gm, '')).toBe(
|
2023-01-27 17:52:22 +00:00
|
|
|
'<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>'
|
2021-04-30 09:51:31 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Make sure getAttribute() works, used in other tests
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(node.getAttribute('xmlns')).toBe('http://www.w3.org/2000/svg');
|
|
|
|
expect(node.getAttribute('aria-hidden')).toBe('true');
|
2021-04-30 09:51:31 +00:00
|
|
|
|
|
|
|
// Make sure style exists
|
|
|
|
const style = node.style;
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(typeof style).toBe('object');
|
2021-04-30 09:51:31 +00:00
|
|
|
});
|
|
|
|
});
|