2021-09-27 14:28:22 +00:00
|
|
|
/**
|
|
|
|
* @jest-environment jsdom
|
|
|
|
*/
|
2021-05-06 21:28:14 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
2021-09-27 14:28:22 +00:00
|
|
|
// Link to alias
|
|
|
|
import { Icon } from '../../offline';
|
2021-05-06 21:28:14 +00:00
|
|
|
|
|
|
|
describe('Empty icon', () => {
|
|
|
|
test('basic test', () => {
|
|
|
|
const wrapper = mount(Icon, {
|
|
|
|
propsData: {},
|
|
|
|
});
|
|
|
|
|
2021-09-27 14:28:22 +00:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe('');
|
2021-05-06 21:28:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('with child node', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon><i class="fa fa-home" /></Icon>`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-09-27 14:28:22 +00:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(
|
2021-05-06 21:28:14 +00:00
|
|
|
'<i class="fa fa-home"></i>'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('with text child node', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon>icon</Icon>`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-09-27 14:28:22 +00:00
|
|
|
expect(wrapper.text()).toBe('icon');
|
2021-05-06 21:28:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('with multiple childen', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon><i class="fa fa-home" /> Home icon</Icon>`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-09-27 14:28:22 +00:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(
|
2021-05-06 21:28:14 +00:00
|
|
|
'<span><i class="fa fa-home"></i> Home icon</span>'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|