Skip to content

Commit

Permalink
add tests for Vue
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Mar 22, 2023
1 parent d30cc25 commit e8e2c5e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions web_src/js/svg.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {expect, test} from 'vitest';
import {svg, svgParseOuterInner} from './svg.js';
import {svg, SvgIcon, svgParseOuterInner} from './svg.js';
import {createApp, h} from 'vue';

test('svg', () => {
expect(svg('octicon-repo')).toMatch(/^<svg/);
Expand All @@ -12,4 +13,15 @@ test('svgParseOuterInner', () => {
expect(svgOuter.nodeName).toMatch('svg');
expect(svgOuter.classList.contains('octicon-repo')).toBeTruthy();
expect(svgInnerHtml).toContain('<path');
})
});

test('SvgIcon', () => {
const root = document.createElement('div');
createApp({render: () => h(SvgIcon, {name: 'octicon-link', size: 24, class: 'base', className: 'extra'})}).mount(root);
expect(root.firstChild.nodeName).toEqual('svg');
expect(root.firstChild.getAttribute('width')).toEqual('24');
expect(root.firstChild.getAttribute('height')).toEqual('24');
expect(root.firstChild.classList.contains('octicon-link')).toBeTruthy();
expect(root.firstChild.classList.contains('base')).toBeTruthy();
expect(root.firstChild.classList.contains('extra')).toBeTruthy();
});

0 comments on commit e8e2c5e

Please sign in to comment.