steps.spec.js
4.34 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import { createVue, destroyVM, waitImmediate } from '../util';
describe('Steps', () => {
let vm;
afterEach(() => {
destroyVM(vm);
});
it('create', () => {
vm = createVue(`
<el-steps>
<el-step title="step1"></el-step>
<el-step title="step2"></el-step>
<el-step title="step3"></el-step>
</el-steps>
`);
expect(vm.$el.querySelectorAll('.el-step')).to.length(3);
});
it('space', async() => {
vm = createVue(`
<el-steps>
<el-step title="step1"></el-step>
<el-step title="step2"></el-step>
<el-step title="step3"></el-step>
</el-steps>
`, true);
const vm2 = createVue(`
<el-steps :space="100">
<el-step title="step1"></el-step>
<el-step title="step2"></el-step>
<el-step title="step3"></el-step>
<el-step title="step4"></el-step>
</el-steps>
`, true);
await waitImmediate();
const stepElm = vm.$el.querySelector('.el-step');
const stepElm2 = vm2.$el.querySelector('.el-step');
expect(getComputedStyle(stepElm).flexBasis).to.equal('50%');
expect(getComputedStyle(stepElm2).flexBasis).to.equal('100px');
});
it('processStatus', done => {
vm = createVue(`
<el-steps :active="1" process-status="error">
<el-step title="step1"></el-step>
<el-step title="step2"></el-step>
<el-step title="step3"></el-step>
</el-steps>
`);
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(1);
done();
});
});
it('update processStatus', done => {
vm = createVue({
template: `
<el-steps :active="1" :process-status="processStatus">
<el-step title="abc"></el-step>
<el-step title="abc2"></el-step>
</el-steps>
`,
data() {
return { processStatus: 'error' };
}
});
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(1);
vm.processStatus = 'process';
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-process')).to.length(1);
done();
});
});
});
it('finishStatus', done => {
vm = createVue(`
<el-steps :active="1" finish-status="error">
<el-step title="abc"></el-step>
<el-step title="abc2"></el-step>
</el-steps>
`);
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(1);
done();
});
});
it('active', done => {
vm = createVue({
template: `
<el-steps :active="active" finish-status="error">
<el-step title="abc"></el-step>
<el-step title="abc2"></el-step>
</el-steps>
`,
data() {
return { active: 0 };
}
});
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(0);
vm.active = 2;
vm.$nextTick(_ => {
expect(vm.$el.querySelectorAll('.el-step__head.is-error')).to.length(2);
done();
});
});
});
it('create vertical', () => {
vm = createVue(`
<el-steps direction="vertical">
<el-step title="aaa"></el-step>
<el-step title="bbb"></el-step>
</el-steps>
`);
expect(vm.$el.querySelector('.is-vertical')).to.exist;
});
it('vertical:height', async() => {
vm = createVue(`
<el-steps direction="vertical" :space="200">
<el-step title="aaa"></el-step>
<el-step title="bbb"></el-step>
</el-steps>
`, true);
await waitImmediate();
const stepElm = vm.$el.querySelector('.el-step');
expect(getComputedStyle(stepElm).flexBasis).to.equal('200px');
});
it('step:status=error', done => {
vm = createVue(`
<el-steps :active="2" process-status="process" finish-status="success" direction="horizontal">
<el-step title="step1"></el-step>
<el-step title="step2" status="error"></el-step>
<el-step title="step3"></el-step>
</el-steps>
`);
vm.$nextTick(_ => {
const errorLine = vm.$el.querySelector('.el-step:nth-child(2) .el-step__line-inner');
expect(errorLine.getBoundingClientRect().width).to.equal(0);
const nextStep = vm.$el.querySelector('.el-step:nth-child(3) .el-step__head');
expect(nextStep.classList.contains('is-wait')).to.equal(true);
done();
});
});
});