forked from EnergySage/es-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEsCollapse.spec.js
80 lines (73 loc) · 2.59 KB
/
EsCollapse.spec.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { mount } from '@vue/test-utils';
import EsCollapse from '@/src/lib-components/EsCollapse.vue';
import EsButton from '@/src/lib-components/EsButton.vue';
import jestVue from '@/tests/jest.vue.config';
describe('EsCollapse', () => {
// Basic test; should exist for most components
test('<EsCollapse />', async () => {
const wrapper = mount(EsCollapse, {
...jestVue,
slots: {
title: 'My Title',
default: 'Lorem ipsum dolor sit amet, consectetur adipiscing.',
},
propsData: {
id: 'myId',
},
});
const a11y = await axe(wrapper.element);
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
expect(a11y).toHaveNoViolations();
});
test('EsButton exists', () => {
const wrapper = mount(EsCollapse, {
...jestVue,
slots: {
title: 'My Title',
default: 'Lorem ipsum dolor sit amet, consectetur adipiscing.',
},
propsData: {
id: 'myId',
},
});
expect(wrapper.findComponent(EsButton).exists()).toBe(true);
expect(wrapper.html()).toMatchSnapshot();
});
test('Title and default slot exist inside EsButton', async () => {
const wrapper = mount(EsCollapse, {
...jestVue,
slots: {
title: 'My Title',
default: 'Lorem ipsum dolor sit amet, consectetur adipiscing.',
},
propsData: {
id: 'myId',
},
});
const box = wrapper.findComponent(EsButton);
await box.trigger('click');
expect(box.text()).toContain('My Title');
expect(wrapper.text()).toBe('My Title Lorem ipsum dolor sit amet, consectetur adipiscing.');
expect(wrapper.html()).toMatchSnapshot();
});
test('Icons switch upon button click', async () => {
const wrapper = mount(EsCollapse, {
...jestVue,
slots: {
title: 'My Title',
default: 'Lorem ipsum dolor sit amet, consectetur adipiscing.',
},
propsData: {
id: 'myId',
},
});
const box = wrapper.findComponent(EsButton);
const content = wrapper.find('.collapse');
expect(content.isVisible()).toBe(false);
await box.trigger('click');
// TODO: Check SVG changed class
expect(content.isVisible()).toBe(true);
expect(wrapper.html()).toMatchSnapshot();
});
});