-
-
Notifications
You must be signed in to change notification settings - Fork 404
/
Copy pathtime-range.test.js
47 lines (42 loc) · 1.27 KB
/
time-range.test.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
import { mount } from '@vue/test-utils';
import TimeRange from '../src/time/time-range';
let wrapper;
afterEach(() => {
wrapper.destroy();
});
describe('TimeRange', () => {
it('render: correct classes of the columns', () => {
wrapper = mount(TimeRange, {
propsData: {
format: 'hh:mm a',
minuteStep: 30,
hourStep: 2,
value: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)],
},
});
expect(wrapper.element).toMatchSnapshot();
});
it('feat: change the end time when start > end', () => {
wrapper = mount(TimeRange, {
propsData: {
value: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)],
},
});
const hour = wrapper.find('[data-type=hour] li:nth-child(20)');
hour.trigger('click');
expect(wrapper.emitted().select[0][0]).toEqual([
new Date(2019, 9, 4, 19, 30, 0),
new Date(2019, 9, 4, 19, 30, 0),
]);
});
it('supports defaultValue is Array', () => {
wrapper = mount(TimeRange, {
propsData: {
defaultValue: [new Date(2019, 9, 1, 10), new Date(2019, 11, 1, 12)],
},
});
const actived = wrapper.findAll('.active');
expect(actived.at(0).text()).toBe('10');
expect(actived.at(3).text()).toBe('12');
});
});