2021-05-05 19:24:26 +03:00
|
|
|
import { mount } from '@vue/test-utils';
|
2021-09-27 16:58:47 +03:00
|
|
|
// Import from alias
|
|
|
|
import { Icon } from '../../offline';
|
2022-03-19 13:19:52 +02:00
|
|
|
import { emptyString } from '../empty';
|
2021-05-05 19:24:26 +03:00
|
|
|
|
|
|
|
describe('Empty icon', () => {
|
|
|
|
test('basic test', () => {
|
|
|
|
const wrapper = mount(Icon, {
|
|
|
|
props: {},
|
|
|
|
});
|
|
|
|
|
2022-03-19 13:19:52 +02:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(emptyString);
|
2021-05-05 19:24:26 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('with child node', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
|
|
|
template: `<Icon><i class="fa fa-home" /></Icon>`,
|
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-09-27 16:58:47 +03:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(
|
2021-05-05 19:24:26 +03: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 16:58:47 +03:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe('icon');
|
2021-05-05 19:24:26 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
test('with multiple childen', () => {
|
|
|
|
const Wrapper = {
|
|
|
|
components: { Icon },
|
2022-01-11 12:37:20 +02:00
|
|
|
template: `<Icon><i class="fa fa-home" />Home icon</Icon>`,
|
2021-05-05 19:24:26 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const wrapper = mount(Wrapper, {});
|
2021-09-27 16:58:47 +03:00
|
|
|
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(
|
2022-01-11 12:37:20 +02:00
|
|
|
'<i class="fa fa-home"></i>Home icon'
|
2021-05-05 19:24:26 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|