[improvement] DatetimePicker: add more test cases (#4029)

This commit is contained in:
neverland 2019-08-02 11:19:28 +08:00 committed by GitHub
parent 70a014e388
commit 6dc1af7ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 0 deletions

View File

@ -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>
`;

View 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();
});