forked from EnergySage/es-ds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EsSupport.spec.js
94 lines (83 loc) · 2.89 KB
/
EsSupport.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import { mount } from '@vue/test-utils';
import EsSupport from '@/src/lib-components/EsSupport.vue';
import jestVue from '@/tests/jest.vue.config';
import { BImg } from 'bootstrap-vue';
describe('EsSupport', () => {
// Basic test; should exist for most components
const slots = {
default: 'Need help signing up?',
};
test('<EsSupport />', async () => {
const wrapper = mount(EsSupport, {
...jestVue,
slots,
propsData: {
link: 'https://www.google.com/',
src: 'https://via.placeholder.com/200x100',
},
});
const a11y = await axe(wrapper.element);
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
expect(a11y).toHaveNoViolations();
});
test('<EsSupport variant="cool" />', async () => {
const wrapper = mount(EsSupport, {
...jestVue,
slots,
propsData: {
link: 'https://www.google.com/',
src: 'https://via.placeholder.com/200x100',
variant: 'cool',
},
});
const a11y = await axe(wrapper.element);
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
expect(a11y).toHaveNoViolations();
});
// Test Support Title works
test('Support title slot exists', async () => {
const wrapper = mount(EsSupport, {
...jestVue,
slots,
propsData: {
link: 'https://www.google.com/',
src: 'https://via.placeholder.com/200x100',
},
});
const titleSlot = wrapper.vm.$slots.default;
expect(titleSlot[0].text).toBe('Need help signing up?');
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
});
// Support text exists
test('Support text exists', async () => {
const wrapper = mount(EsSupport, {
...jestVue,
slots,
propsData: {
link: 'https://www.google.com/',
src: 'https://via.placeholder.com/200x100',
},
});
const supportLink = wrapper.find('.supportLink');
expect(supportLink.text()).toBe('Schedule a free call with your EnergySage Advisor.');
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
});
// Image component exists
test('Image exists', async () => {
const wrapper = mount(EsSupport, {
...jestVue,
slots,
propsData: {
link: 'https://www.google.com/',
src: 'https://via.placeholder.com/200x100',
},
});
expect(wrapper.findComponent(BImg).exists()).toBe(true);
expect(wrapper.vm).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
});
});