result.spec.js
3.56 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import { createVue, destroyVM, waitImmediate } from '../util';
const AXIOM = 'Rem is the best girl';
describe('Result', () => {
let vm;
afterEach(() => {
destroyVM(vm);
});
it('render test', () => {
vm = createVue({
template: '<el-result />'
}, true);
expect(vm.$el.querySelector('.el-result__icon')).to.exist;
expect(Array.from(vm.$el.classList)).to.contain('el-result');
});
it('should render title props', () => {
vm = createVue({
template: '<el-result :title="title"/>',
data() {
return {
title: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__title').innerText).to.be.equal(AXIOM);
});
it('should render sub-title props', () => {
vm = createVue({
template: '<el-result :sub-title="subTitle"/>',
data() {
return {
subTitle: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__subtitle').innerText).to.be.equal(AXIOM);
});
it('should render icon props', async() => {
vm = createVue({
template: '<el-result :icon="icon"/>',
data() {
return {
icon: 'success'
};
}
}, true);
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-success');
vm.icon = 'error';
await waitImmediate();
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-error');
vm.icon = 'warning';
await waitImmediate();
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-warning');
vm.icon = 'info';
await waitImmediate();
expect(vm.$el.querySelector('.el-result__icon svg')).to.exist;
expect(Array.from(vm.$el.querySelector('.el-result__icon svg').classList)).to.contain('icon-info');
});
it('should render icon slots', () => {
vm = createVue({
template: '<el-result><template slot="icon">{{icon}}</template></el-result>',
data() {
return {
icon: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__icon')).to.exist;
expect(vm.$el.querySelector('.el-result__icon').innerText).to.be.equal(AXIOM);
});
it('should render title slots', () => {
vm = createVue({
template: '<el-result><template slot="title">{{title}}</template></el-result>',
data() {
return {
title: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__title')).to.exist;
expect(vm.$el.querySelector('.el-result__title').innerText).to.be.equal(AXIOM);
});
it('should render sub-title slots', () => {
vm = createVue({
template: '<el-result><template slot="subTitle">{{subTitle}}</template></el-result>',
data() {
return {
subTitle: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__subtitle')).to.exist;
expect(vm.$el.querySelector('.el-result__subtitle').innerText).to.be.equal(AXIOM);
});
it('should render extra slots', () => {
vm = createVue({
template: '<el-result><template slot="extra">{{extra}}</template></el-result>',
data() {
return {
extra: AXIOM
};
}
}, true);
expect(vm.$el.querySelector('.el-result__extra')).to.exist;
expect(vm.$el.querySelector('.el-result__extra').innerText).to.be.equal(AXIOM);
});
});