2021-09-27 13:58:47 +00:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
2021-05-05 16:24:26 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { Icon } from '../../dist/offline';
|
|
|
|
|
|
|
|
const iconData = {
|
2021-09-27 13:58:47 +00:00
|
|
|
body: '<path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"/>',
|
2021-05-05 16:24:26 +00:00
|
|
|
width: 24,
|
|
|
|
height: 24,
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('Inline attribute', () => {
|
|
|
|
test('string', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" inline="true" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).toContain('style="vertical-align: -0.125em;"');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('false string', () => {
|
2021-05-11 20:27:13 +00:00
|
|
|
// "false" should be ignored
|
2021-05-05 16:24:26 +00:00
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" inline="false" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-05-11 20:27:13 +00:00
|
|
|
expect(wrapper.html()).not.toContain(
|
|
|
|
'style="vertical-align: -0.125em;"'
|
|
|
|
);
|
2021-05-05 16:24:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('true', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" :inline="true" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).toContain('style="vertical-align: -0.125em;"');
|
|
|
|
});
|
|
|
|
|
|
|
|
test('false', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" :inline="false" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).not.toContain(
|
|
|
|
'style="vertical-align: -0.125em;"'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('inline and style string', () => {
|
|
|
|
// Style goes after vertical-align
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" :inline="true" style="color: red;" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).toContain(
|
2021-05-06 08:21:39 +00:00
|
|
|
'color: red; vertical-align: -0.125em;'
|
2021-05-05 16:24:26 +00:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('inline and style object', () => {
|
|
|
|
// Style goes after vertical-align
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" :inline="true" :style="style" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
style: {
|
|
|
|
color: 'red',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).toContain(
|
2021-05-06 08:21:39 +00:00
|
|
|
'color: red; vertical-align: -0.125em;'
|
2021-05-05 16:24:26 +00:00
|
|
|
);
|
|
|
|
});
|
2021-05-06 08:21:39 +00:00
|
|
|
|
|
|
|
test('inline and style overriding it', () => {
|
|
|
|
// Style goes after vertical-align
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon :icon="icon" :inline="true" :style="style" />`,
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
icon: iconData,
|
|
|
|
style: {
|
|
|
|
verticalAlign: 0,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
|
|
|
expect(wrapper.html()).toContain('style="vertical-align: 0;"');
|
|
|
|
});
|
2021-05-05 16:24:26 +00:00
|
|
|
});
|