fe5108cd
Sergio Crisostomo
Add Time-Picker u...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import { createVue, destroyVM } from '../util';
describe('TimePicker.vue', () => {
let vm;
afterEach(() => {
destroyVM(vm);
});
it('should create a TimePicker component with hours, minutes and seconds', done => {
vm = createVue(`
<Time-Picker></Time-Picker>
`);
const picker = vm.$children[0];
|
75cb2998
Sergio Crisostomo
Add keyboard navi...
|
14
|
picker.handleFocus({type: 'focus'}); // open the picker panels
|
fe5108cd
Sergio Crisostomo
Add Time-Picker u...
|
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
vm.$nextTick(() => {
const spiners = picker.$el.querySelectorAll('.ivu-time-picker-cells-list');
expect(spiners.length).to.equal(3); // hh:mm:ss
expect(spiners[0].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(24);
expect(spiners[1].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(60);
expect(spiners[2].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(60);
done();
});
});
it('should create a TimePicker component with only hours and minutes', done => {
vm = createVue(`
<Time-Picker format="HH:mm"></Time-Picker>
`);
const picker = vm.$children[0];
|
75cb2998
Sergio Crisostomo
Add keyboard navi...
|
31
|
picker.handleFocus({type: 'focus'}); // open the picker panels
|
fe5108cd
Sergio Crisostomo
Add Time-Picker u...
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
vm.$nextTick(() => {
const spiners = picker.$el.querySelectorAll('.ivu-time-picker-cells-list');
expect([...spiners].filter(el => el.style.display != 'none').length).to.equal(2); // hh:mm
expect(spiners[0].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(24);
expect(spiners[1].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(60);
done();
});
});
it('should create a TimePicker component with steps of 15 minutes', done => {
vm = createVue(`
<Time-Picker :steps="[1, 15]"></Time-Picker>
`);
const picker = vm.$children[0];
|
75cb2998
Sergio Crisostomo
Add keyboard navi...
|
47
|
picker.handleFocus({type: 'focus'}); // open the picker panels
|
fe5108cd
Sergio Crisostomo
Add Time-Picker u...
|
48
49
50
51
52
53
54
55
56
57
58
59
60
|
vm.$nextTick(() => {
const spiners = picker.$el.querySelectorAll('.ivu-time-picker-cells-list');
const minutesList = [...spiners[1].querySelectorAll('.ivu-time-picker-cells-cell')];
expect(spiners[0].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(24);
expect(minutesList.map(el => el.textContent).join(',')).to.equal('00,15,30,45');
expect(spiners[1].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(4);
expect(spiners[2].querySelectorAll('.ivu-time-picker-cells-cell').length).to.equal(60);
done();
});
});
});
|