forked from marceloatg/vuetning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.test.js
58 lines (43 loc) · 1.56 KB
/
unit.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import {shallowMount} from '@vue/test-utils'
import SldsButton from './index'
describe('SldsButton', () => {
it('renders props.label when passed', () => {
// shallow mount the button setting a label
const label = 'test label';
const wrapper = shallowMount(SldsButton, {
propsData: {label}
});
// assert button text matches label
expect(wrapper.text()).toMatch(label);
});
it('emits click when clicked', () => {
// shallow mount the button
const wrapper = shallowMount(SldsButton);
// trigger click
wrapper.trigger('click');
// assert event has been emitted
expect(wrapper.emitted().click).toBeTruthy();
});
it('does no emit click when clicked in disabled state', () => {
// shallow mount the button setting a disabled state
const disabled = true;
const wrapper = shallowMount(SldsButton, {
propsData: {disabled}
});
// trigger click
wrapper.trigger('click');
// assert event has not been emitted
expect(wrapper.emitted().click).toBeFalsy();
});
it('does no emit click when clicked when spinner is active', () => {
// shallow mount the button setting a disabled state
const spinner = true;
const wrapper = shallowMount(SldsButton, {
propsData: {spinner}
});
// trigger click
wrapper.trigger('click')
// assert event has not been emitted
expect(wrapper.emitted().click).toBeFalsy();
});
});