Skip to content

Commit e8e2c5e

Browse files
committed
add tests for Vue
1 parent d30cc25 commit e8e2c5e

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

web_src/js/svg.test.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {expect, test} from 'vitest';
2-
import {svg, svgParseOuterInner} from './svg.js';
2+
import {svg, SvgIcon, svgParseOuterInner} from './svg.js';
3+
import {createApp, h} from 'vue';
34

45
test('svg', () => {
56
expect(svg('octicon-repo')).toMatch(/^<svg/);
@@ -12,4 +13,15 @@ test('svgParseOuterInner', () => {
1213
expect(svgOuter.nodeName).toMatch('svg');
1314
expect(svgOuter.classList.contains('octicon-repo')).toBeTruthy();
1415
expect(svgInnerHtml).toContain('<path');
15-
})
16+
});
17+
18+
test('SvgIcon', () => {
19+
const root = document.createElement('div');
20+
createApp({render: () => h(SvgIcon, {name: 'octicon-link', size: 24, class: 'base', className: 'extra'})}).mount(root);
21+
expect(root.firstChild.nodeName).toEqual('svg');
22+
expect(root.firstChild.getAttribute('width')).toEqual('24');
23+
expect(root.firstChild.getAttribute('height')).toEqual('24');
24+
expect(root.firstChild.classList.contains('octicon-link')).toBeTruthy();
25+
expect(root.firstChild.classList.contains('base')).toBeTruthy();
26+
expect(root.firstChild.classList.contains('extra')).toBeTruthy();
27+
});

0 commit comments

Comments
 (0)