2021-09-27 13:29:45 +00:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
2021-05-01 20:38:56 +00:00
|
|
|
import { render } from '@testing-library/svelte';
|
2021-09-27 13:29:45 +00:00
|
|
|
import Icon from '../../offline';
|
2021-05-01 20:38:56 +00:00
|
|
|
|
|
|
|
const iconData = {
|
2021-05-11 20:27:13 +00:00
|
|
|
body: '<path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"/>',
|
2021-05-01 20:38:56 +00:00
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Inline attribute', () => {
|
|
|
|
test('boolean true', () => {
|
|
|
|
const component = render(Icon, { icon: iconData, inline: true });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
2021-05-01 20:38:56 +00:00
|
|
|
const style = node.style;
|
|
|
|
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(style.verticalAlign).toBe('-0.125em');
|
2021-05-01 20:38:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('string true', () => {
|
|
|
|
const component = render(Icon, { icon: iconData, inline: 'true' });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
2021-05-01 20:38:56 +00:00
|
|
|
const style = node.style;
|
|
|
|
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(style.verticalAlign).toBe('-0.125em');
|
2021-05-01 20:38:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('false', () => {
|
|
|
|
const component = render(Icon, { icon: iconData, inline: false });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
2021-05-01 20:38:56 +00:00
|
|
|
const style = node.style;
|
|
|
|
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(style.verticalAlign).toBe('');
|
2021-05-01 20:38:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('false string', () => {
|
2021-05-11 20:27:13 +00:00
|
|
|
// "false" should be ignored
|
2021-05-01 20:38:56 +00:00
|
|
|
const component = render(Icon, { icon: iconData, inline: 'false' });
|
2021-09-27 13:29:45 +00:00
|
|
|
const node = component.container.querySelector('svg')!;
|
2021-05-01 20:38:56 +00:00
|
|
|
const style = node.style;
|
|
|
|
|
2021-09-27 13:29:45 +00:00
|
|
|
expect(style.verticalAlign).toBe('');
|
2021-05-01 20:38:56 +00:00
|
|
|
});
|
|
|
|
});
|