mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] DatetimePicker: add more test cases (#4029)
This commit is contained in:
parent
70a014e388
commit
6dc1af7ff0
@ -0,0 +1,28 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`time type 1`] = `
|
||||
<div class="van-picker van-datetime-picker">
|
||||
<div class="van-hairline--top-bottom van-picker__toolbar">
|
||||
<div role="button" tabindex="0" class="van-picker__cancel">取消</div>
|
||||
<div role="button" tabindex="0" class="van-picker__confirm">确认</div>
|
||||
</div>
|
||||
<!---->
|
||||
<div class="van-picker__columns" style="height: 220px;">
|
||||
<div class="van-picker-column">
|
||||
<ul class="van-picker-column__wrapper" style="transform: translate3d(0, 88px, 0); transition-duration: 0ms; transition-property: none; line-height: 44px;">
|
||||
<li class="van-ellipsis van-picker-column__item van-picker-column__item--selected" style="height: 44px;">22</li>
|
||||
<li class="van-ellipsis van-picker-column__item" style="height: 44px;">23</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="van-picker-column">
|
||||
<ul class="van-picker-column__wrapper" style="transform: translate3d(0, 88px, 0); transition-duration: 0ms; transition-property: none; line-height: 44px;">
|
||||
<li class="van-ellipsis van-picker-column__item van-picker-column__item--selected" style="height: 44px;">58</li>
|
||||
<li class="van-ellipsis van-picker-column__item" style="height: 44px;">59</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="van-picker__mask" style="background-size: 100% 88px;"></div>
|
||||
<div class="van-hairline--top-bottom van-picker__frame" style="height: 44px;"></div>
|
||||
</div>
|
||||
<!---->
|
||||
</div>
|
||||
`;
|
32
src/datetime-picker/test/datetime-picker.spec.js
Normal file
32
src/datetime-picker/test/datetime-picker.spec.js
Normal file
@ -0,0 +1,32 @@
|
||||
import DatetimePicker from '..';
|
||||
import { mount } from '../../../test/utils';
|
||||
|
||||
test('confirm & cancel event', () => {
|
||||
const onConfirm = jest.fn();
|
||||
const onCancel = jest.fn();
|
||||
|
||||
const wrapper = mount(DatetimePicker, {
|
||||
listeners: {
|
||||
confirm: onConfirm,
|
||||
cancel: onCancel
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.find('.van-picker__confirm').trigger('click');
|
||||
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||
|
||||
wrapper.find('.van-picker__cancel').trigger('click');
|
||||
expect(onCancel).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('time type', () => {
|
||||
const wrapper = mount(DatetimePicker, {
|
||||
propsData: {
|
||||
type: 'time',
|
||||
minHour: 22,
|
||||
minMinute: 58
|
||||
}
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user