Skip to content

Commit

Permalink
test: writes test for icon component
Browse files Browse the repository at this point in the history
  • Loading branch information
gokh4nozturk authored and Gökhan Öztürk committed Aug 23, 2022
1 parent 269a8f2 commit f4175ff
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/components/Icon/__snapshots__/icon.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Vitest Snapshot v1

exports[`Icon > renders properly 1`] = `
<svg
aria-hidden="true"
fill="currentColor"
style="color: rgb(255, 255, 255);"
viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5 4a1 1 0 00-2 0v7.268a2 2 0 000 3.464V16a1 1 0 102 0v-1.268a2 2 0 000-3.464V4zM11 4a1 1 0 10-2 0v1.268a2 2 0 000 3.464V16a1 1 0 102 0V8.732a2 2 0 000-3.464V4zM16 3a1 1 0 011 1v7.268a2 2 0 010 3.464V16a1 1 0 11-2 0v-1.268a2 2 0 010-3.464V4a1 1 0 011-1z"
/>
</svg>
`;
28 changes: 28 additions & 0 deletions src/components/Icon/icon.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { describe, it, expect } from 'vitest';

import { mount } from '@vue/test-utils';
import Icon from './Icon.vue';

describe('Icon', () => {
it('renders properly', () => {
const wrapper = mount(Icon, {
props: {
name: 'AdjustmentsIcon',
size: '24',
color: 'rgb(255, 255, 255)',
kind: 'solid',
},
});
expect(wrapper.exists()).toBe(true);
expect(wrapper.find('svg').exists()).toBe(true);
expect(wrapper.find('svg').element.getAttribute('aria-hidden')).toBe(
'true'
);
expect(wrapper.find('svg').element.getAttribute('style')).toBe(
'color: rgb(255, 255, 255);'
);
expect(wrapper.find('svg').element.getAttribute('fill')).toBe(
'currentColor'
);
});
});

0 comments on commit f4175ff

Please sign in to comment.