feat(Calendar): support max-range when type is multiple (#6202)

* feat(Calendar): support max-range when type is multiple

* docs: fix version tag
This commit is contained in:
neverland
2020-05-03 09:11:14 +08:00
committed by GitHub
parent 8348819cc8
commit 3cda85e122
4 changed files with 45 additions and 4 deletions
+23 -2
View File
@@ -2,7 +2,7 @@ import Calendar from '..';
import { mount, later } from '../../../test';
import { minDate, maxDate, formatRange, formatDate } from './utils';
test('max-range prop when showConfirm is false', async () => {
test('max-range prop when type is range and showConfirm is false', async () => {
const wrapper = mount(Calendar, {
propsData: {
type: 'range',
@@ -27,7 +27,7 @@ test('max-range prop when showConfirm is false', async () => {
expect(wrapper.emitted('confirm')).toBeFalsy();
});
test('max-range prop when showConfirm is true', async () => {
test('max-range prop when type is range and showConfirm is true', async () => {
const wrapper = mount(Calendar, {
propsData: {
type: 'range',
@@ -51,6 +51,27 @@ test('max-range prop when showConfirm is true', async () => {
expect(wrapper.emitted('confirm')).toBeFalsy();
});
test('max-range prop when type is multiple', async () => {
const wrapper = mount(Calendar, {
propsData: {
type: 'multiple',
minDate,
maxDate,
maxRange: 2,
poppable: false,
showConfirm: false,
},
});
await later();
const days = wrapper.findAll('.van-calendar__day');
days.at(13).trigger('click');
days.at(14).trigger('click');
expect(wrapper.emitted('select').length).toEqual(1);
});
test('show-title prop', () => {
const wrapper = mount(Calendar, {
propsData: {