You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svg.test.js 1.1KB

123456789101112131415161718192021222324252627
  1. import {svg, SvgIcon, svgParseOuterInner} from './svg.js';
  2. import {createApp, h} from 'vue';
  3. test('svg', () => {
  4. expect(svg('octicon-repo')).toMatch(/^<svg/);
  5. expect(svg('octicon-repo', 16)).toContain('width="16"');
  6. expect(svg('octicon-repo', 32)).toContain('width="32"');
  7. });
  8. test('svgParseOuterInner', () => {
  9. const {svgOuter, svgInnerHtml} = svgParseOuterInner('octicon-repo');
  10. expect(svgOuter.nodeName).toMatch('svg');
  11. expect(svgOuter.classList.contains('octicon-repo')).toBeTruthy();
  12. expect(svgInnerHtml).toContain('<path');
  13. });
  14. test('SvgIcon', () => {
  15. const root = document.createElement('div');
  16. createApp({render: () => h(SvgIcon, {name: 'octicon-link', size: 24, class: 'base', className: 'extra'})}).mount(root);
  17. const node = root.firstChild;
  18. expect(node.nodeName).toEqual('svg');
  19. expect(node.getAttribute('width')).toEqual('24');
  20. expect(node.getAttribute('height')).toEqual('24');
  21. expect(node.classList.contains('octicon-link')).toBeTruthy();
  22. expect(node.classList.contains('base')).toBeTruthy();
  23. expect(node.classList.contains('extra')).toBeTruthy();
  24. });