Skip to content

Commit

Permalink
chore: writes unit test for button component
Browse files Browse the repository at this point in the history
  • Loading branch information
gokh4nozturk authored and Gökhan Öztürk committed Aug 18, 2022
1 parent bcadd19 commit 2faebd1
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/components/Button/Button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@ import Button from './Button.vue';

describe('Button', () => {
it('renders properly', () => {
const wrapper = mount(Button, { props: { label: 'Hello Vitest' } });
const wrapper = mount(Button, {
props: {
label: 'Hello Vitest',
role: 'primary',
size: 'large',
type: 'button',
backgroundColor: '#fff',
},
});
expect(wrapper.text()).toContain('Hello Vitest');
expect(wrapper.classes()).toContain('button');
expect(wrapper.classes()).toContain('button--primary');
expect(wrapper.attributes('type')).toBe('button');
expect(wrapper.exists()).toBe(true);
expect(wrapper.find('.button').attributes('type')).toBe('button');
describe('when clicked', () => {
it('emits an event', () => {
wrapper.trigger('click');
expect(wrapper.emitted().click).toBeTruthy();
}).timeout(0);
});
it('renders a button', () => {
expect(wrapper.find('.button').exists()).toBe(true);
});
});
});

0 comments on commit 2faebd1

Please sign in to comment.