2
0
mirror of https://github.com/iconify/iconify.git synced 2024-12-04 18:23:17 +00:00

chore: fix ssr prop in vue component

This commit is contained in:
Vjacheslav Trushkin 2024-11-04 08:40:36 +02:00
parent 69b6290f7b
commit 25bce96682
2 changed files with 31 additions and 1 deletions

View File

@ -127,6 +127,7 @@ export const render = (
case 'style':
case 'onLoad':
case 'mode':
case 'ssr':
break;
// Boolean attributes

View File

@ -1,6 +1,6 @@
import { nextTick } from 'vue';
import { mount } from '@vue/test-utils';
import { Icon } from '../../';
import { Icon, setCustomIconLoader, loadIcon } from '../../';
const iconData = {
body: '<path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"/>',
@ -44,4 +44,33 @@ describe('Creating component', () => {
'<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 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>'
);
});
test('custom loader', async () => {
const prefix = 'customLoader';
const name = 'TestIcon';
// Set custom loader and load icon data
setCustomIconLoader(() => {
return iconData;
}, prefix);
await loadIcon(`${prefix}:${name}`);
// Create component
const Wrapper = {
components: { Icon },
template: `<Icon :icon='icon' ssr />`,
data() {
return {
icon: `${prefix}:${name}`,
};
},
};
const wrapper = mount(Wrapper, {});
await nextTick();
expect(wrapper.html().replace(/\s*\n\s*/g, '')).toBe(
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" viewBox="0 0 24 24" class="iconify iconify--${prefix}"><path d="M4 19h16v2H4zm5-4h11v2H9zm-5-4h16v2H4zm0-8h16v2H4zm5 4h11v2H9z" fill="currentColor"></path></svg>`
);
});
});