chore: bump @vant/cli@3.5.1 (#8221)

This commit is contained in:
neverland
2021-02-26 10:24:53 +08:00
committed by GitHub
parent 6aa2beeda4
commit 1dbe9c54eb
23 changed files with 403 additions and 203 deletions
+6 -6
View File
@@ -10,8 +10,8 @@ test('should emit select event after clicking option', () => {
});
wrapper.find('.van-action-sheet__item').trigger('click');
expect(wrapper.emitted('select').length).toEqual(1);
expect(wrapper.emitted('select')[0]).toEqual([
expect(wrapper.emitted('select')!.length).toEqual(1);
expect(wrapper.emitted('select')![0]).toEqual([
{
name: 'Option',
},
@@ -66,7 +66,7 @@ test('should emit cancel event after clicking cancel button', () => {
});
wrapper.find('.van-action-sheet__cancel').trigger('click');
expect(wrapper.emitted('cancel').length).toEqual(1);
expect(wrapper.emitted('cancel')!.length).toEqual(1);
});
test('should render subname correctly', () => {
@@ -204,8 +204,8 @@ test('should close after clicking option if close-on-click-action prop is true',
const option = wrapper.find('.van-action-sheet__item');
option.trigger('click');
expect(wrapper.emitted('update:show').length).toEqual(1);
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('update:show')!.length).toEqual(1);
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
});
test('should emit click-overlay event and closed after clicking the overlay', () => {
@@ -218,7 +218,7 @@ test('should emit click-overlay event and closed after clicking the overlay', ()
});
wrapper.find('.van-overlay').trigger('click');
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
expect(onClickOverlay).toHaveBeenCalledTimes(1);
});
+2 -2
View File
@@ -36,7 +36,7 @@ test('should emit select event after clicking radio icon', () => {
wrapper.find('.van-radio__icon').trigger('click');
expect(wrapper.emitted('select')[0]).toEqual([list[0], 0]);
expect(wrapper.emitted('select')![0]).toEqual([list[0], 0]);
});
test('should emit click-item event when item is clicked', () => {
@@ -48,5 +48,5 @@ test('should emit click-item event when item is clicked', () => {
wrapper.find('.van-address-item').trigger('click');
expect(wrapper.emitted('click-item')[0]).toEqual([list[0], 0]);
expect(wrapper.emitted('click-item')![0]).toEqual([list[0], 0]);
});
+1 -1
View File
@@ -5,7 +5,7 @@ test('should emit click event', () => {
const wrapper = mount(Button);
wrapper.trigger('click');
expect(wrapper.emitted('click').length).toEqual(1);
expect(wrapper.emitted('click')!.length).toEqual(1);
});
test('should not emit click event when disabled', () => {
+1 -1
View File
@@ -20,7 +20,7 @@ test('should emit click-thumb event after clicking thumb', () => {
});
wrapper.find('.van-card__thumb').trigger('click');
expect(wrapper.emitted('click-thumb').length).toEqual(1);
expect(wrapper.emitted('click-thumb')!.length).toEqual(1);
});
test('should render price and num slot correctly', () => {
+6 -6
View File
@@ -14,7 +14,7 @@ test('should emit change event when active option changed', async () => {
wrapper.find('.van-cascader__option').trigger('click');
const firstOption = options[0];
expect(wrapper.emitted('change')[0]).toEqual([
expect(wrapper.emitted('change')![0]).toEqual([
{
value: firstOption.value,
tabIndex: 0,
@@ -28,7 +28,7 @@ test('should emit change event when active option changed', async () => {
.find('.van-cascader__option')
.trigger('click');
const secondOption = options[0].children[0];
expect(wrapper.emitted('change')[1]).toEqual([
expect(wrapper.emitted('change')![1]).toEqual([
{
value: secondOption.value,
tabIndex: 1,
@@ -47,7 +47,7 @@ test('should emit finish event when all options is selected', async () => {
await later();
wrapper.find('.van-cascader__option').trigger('click');
expect(wrapper.emitted('finish')[0]).toEqual([
expect(wrapper.emitted('finish')![0]).toEqual([
{
value: option.value,
tabIndex: 0,
@@ -59,7 +59,7 @@ test('should emit finish event when all options is selected', async () => {
test('should emit close event when close icon is clicked', () => {
const wrapper = mount(Cascader);
wrapper.find('.van-cascader__close-icon').trigger('click');
expect(wrapper.emitted('close')[0]).toBeTruthy();
expect(wrapper.emitted('close')![0]).toBeTruthy();
});
test('should not render close icon when closeable is false', () => {
@@ -146,7 +146,7 @@ test('should allow to custom field names', async () => {
wrapper.find('.van-cascader__option').trigger('click');
const firstOption = options[0];
expect(wrapper.emitted('change')[0]).toEqual([
expect(wrapper.emitted('change')![0]).toEqual([
{
value: firstOption.code,
tabIndex: 0,
@@ -160,7 +160,7 @@ test('should allow to custom field names', async () => {
.find('.van-cascader__option')
.trigger('click');
const secondOption = options[0].items[0];
expect(wrapper.emitted('change')[1]).toEqual([
expect(wrapper.emitted('change')![1]).toEqual([
{
value: secondOption.code,
tabIndex: 1,
+5 -5
View File
@@ -6,11 +6,11 @@ test('should emit "update:modelValue" event when checkbox icon is clicked', asyn
const icon = wrapper.find('.van-checkbox__icon');
icon.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([true]);
await wrapper.setProps({ modelValue: true });
icon.trigger('click');
expect(wrapper.emitted('update:modelValue')[1]).toEqual([false]);
expect(wrapper.emitted('update:modelValue')![1]).toEqual([false]);
});
test('should emit change event when modelValue is changed', async () => {
@@ -19,11 +19,11 @@ test('should emit change event when modelValue is changed', async () => {
const icon = wrapper.find('.van-checkbox__icon');
icon.trigger('click');
await wrapper.setProps({ modelValue: true });
expect(wrapper.emitted('change')[0]).toEqual([true]);
expect(wrapper.emitted('change')![0]).toEqual([true]);
icon.trigger('click');
await wrapper.setProps({ modelValue: false });
expect(wrapper.emitted('change')[1]).toEqual([false]);
expect(wrapper.emitted('change')![1]).toEqual([false]);
});
test('should not emit "update:modelValue" event when checkbox icon is disabled and clicked', () => {
@@ -59,7 +59,7 @@ test('should emit "update:modelValue" event when label is clicked', () => {
const icon = wrapper.find('.van-checkbox__label');
icon.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([true]);
});
test('should not emit "update:modelValue" event when label is disabled and clicked', () => {
+1 -1
View File
@@ -4,7 +4,7 @@ import { mount } from '../../../test';
test('should emit click event when clicked', () => {
const wrapper = mount(ContactCard);
wrapper.trigger('click');
expect(wrapper.emitted('click').length).toEqual(1);
expect(wrapper.emitted('click')!.length).toEqual(1);
});
test('should not emit click event when editable is false and clicked ', () => {
+2 -2
View File
@@ -49,14 +49,14 @@ test('should emit save event after submitting form', async () => {
});
await submitForm(wrapper);
expect(wrapper.emitted<[ContactInfo]>('save')[0][0]).toEqual(contactInfo);
expect(wrapper.emitted<[ContactInfo]>('save')![0][0]).toEqual(contactInfo);
});
test('should watch contact info', async () => {
const wrapper = mount(ContactEdit);
await wrapper.setProps({ contactInfo });
await submitForm(wrapper);
expect(wrapper.emitted<[ContactInfo]>('save')[0][0]).toEqual(contactInfo);
expect(wrapper.emitted<[ContactInfo]>('save')![0][0]).toEqual(contactInfo);
});
test('should allow deleting contact', async () => {
+5 -5
View File
@@ -18,7 +18,7 @@ test('should render ContactList correctly', () => {
test('should emit add event when add button is clicked', () => {
const wrapper = mount(ContactList);
wrapper.find('.van-contact-list__add').trigger('click');
expect(wrapper.emitted('add').length).toEqual(1);
expect(wrapper.emitted('add')!.length).toEqual(1);
});
test('should emit select event when radio is clicked', () => {
@@ -30,8 +30,8 @@ test('should emit select event when radio is clicked', () => {
wrapper.find('.van-radio__icon').trigger('click');
expect(wrapper.emitted('select').length).toEqual(1);
expect(wrapper.emitted('select')[0]).toEqual([contactInfo, 0]);
expect(wrapper.emitted('select')!.length).toEqual(1);
expect(wrapper.emitted('select')![0]).toEqual([contactInfo, 0]);
});
test('should emit edit event when edit icon is clicked', () => {
@@ -43,6 +43,6 @@ test('should emit edit event when edit icon is clicked', () => {
wrapper.find('.van-contact-list__edit').trigger('click');
expect(wrapper.emitted('edit').length).toEqual(1);
expect(wrapper.emitted('edit')[0]).toEqual([contactInfo, 0]);
expect(wrapper.emitted('edit')!.length).toEqual(1);
expect(wrapper.emitted('edit')![0]).toEqual([contactInfo, 0]);
});
+2 -2
View File
@@ -13,7 +13,7 @@ test('should emit load event after image loaded', async () => {
await wrapper.find('img').trigger('load');
expect(wrapper.emitted<[Event]>('load')[0][0]).toBeTruthy();
expect(wrapper.emitted<[Event]>('load')![0][0]).toBeTruthy();
expect(wrapper.html()).toMatchSnapshot();
});
@@ -37,7 +37,7 @@ test('should emit error event when load image failed', () => {
});
wrapper.find('img').trigger('error');
expect(wrapper.emitted<[Event]>('error')[0][0]).toBeTruthy();
expect(wrapper.emitted<[Event]>('error')![0][0]).toBeTruthy();
});
test('should render loading placeholder when using lazy-load prop', () => {
+1 -1
View File
@@ -4,7 +4,7 @@ import { mount } from '../../../test';
test('should emit focus event when security is touched', () => {
const wrapper = mount(PasswordInput);
wrapper.find('.van-password-input__security').trigger('touchstart');
expect(wrapper.emitted('focus').length).toEqual(1);
expect(wrapper.emitted('focus')!.length).toEqual(1);
});
test('should render error info correctly', () => {
+2 -2
View File
@@ -111,7 +111,7 @@ test('should render success text correctly', async () => {
await later();
// loading
expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([true]);
await wrapper.setProps({ modelValue: true });
// success
@@ -133,7 +133,7 @@ test('should render success slot correctly', async () => {
// loading
const track = wrapper.find('.van-pull-refresh__track');
triggerDrag(track, 0, 100);
expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([true]);
await wrapper.setProps({ modelValue: true });
// success
+2 -2
View File
@@ -37,11 +37,11 @@ test('should emit "update:modelValue" and "change" event when radio is clicked',
await icons[2].trigger('click');
expect(wrapper.vm.result).toEqual('c');
expect(wrapper.emitted('change')[0]).toEqual(['c']);
expect(wrapper.emitted('change')![0]).toEqual(['c']);
await labels[1].trigger('click');
expect(wrapper.vm.result).toEqual('b');
expect(wrapper.emitted('change')[1]).toEqual(['b']);
expect(wrapper.emitted('change')![1]).toEqual(['b']);
await icons[3].trigger('click');
await labels[3].trigger('click');
+2 -2
View File
@@ -13,10 +13,10 @@ test('should emit "update:modelValue" event when radio icon or label is clicked'
const icon = wrapper.find('.van-radio__icon');
const label = wrapper.find('.van-radio__label');
icon.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([props.name]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([props.name]);
label.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([props.name]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([props.name]);
});
test('should not emit "update:modelValue" event when radio icon is disabled and clicked', () => {
+4 -4
View File
@@ -53,7 +53,7 @@ test('should emit select event when an option is clicked', () => {
});
wrapper.find('.van-share-sheet__option').trigger('click');
expect(wrapper.emitted('select')[0]).toEqual([
expect(wrapper.emitted('select')![0]).toEqual([
{ icon: 'wechat', name: 'wechat' },
0,
]);
@@ -68,8 +68,8 @@ test('should emit cancel event when the cancel button is clicked', () => {
wrapper.find('.van-share-sheet__cancel').trigger('click');
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('cancel')[0]).toBeTruthy();
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
expect(wrapper.emitted('cancel')![0]).toBeTruthy();
});
test('should render title and description slot correctly', () => {
@@ -102,5 +102,5 @@ test('should emit click-overlay event when overlay is clicked', async () => {
const overlay = root.querySelector('.van-overlay')!;
trigger(overlay, 'click');
expect(onClickOverlay).toHaveBeenCalledTimes(1);
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
});
+6 -6
View File
@@ -24,7 +24,7 @@ test('should emit "update:modelValue" event after dragging button', () => {
const button = wrapper.find('.van-slider__button');
triggerDrag(button, 50, 0);
expect(wrapper.emitted('update:modelValue').pop()).toEqual([100]);
expect(wrapper.emitted('update:modelValue')!.pop()).toEqual([100]);
});
test('should emit "update:modelValue" event after clicking slider', () => {
@@ -35,7 +35,7 @@ test('should emit "update:modelValue" event after clicking slider', () => {
});
trigger(wrapper, 'click', 100, 0);
expect(wrapper.emitted('update:modelValue').pop()).toEqual([100]);
expect(wrapper.emitted('update:modelValue')!.pop()).toEqual([100]);
});
test('should emit drag-start event when start dragging', () => {
@@ -128,7 +128,7 @@ test('should allow to drag vertical slider', () => {
const button = wrapper.find('.van-slider__button');
triggerDrag(button, 0, 50);
expect(wrapper.emitted('update:modelValue').pop()).toEqual([100]);
expect(wrapper.emitted('update:modelValue')!.pop()).toEqual([100]);
restoreMock();
});
@@ -166,7 +166,7 @@ test('should emit "update:modelValue" event after clicking vertical slider', ()
});
trigger(wrapper, 'click', 0, 100);
expect(wrapper.emitted('update:modelValue').pop()).toEqual([100]);
expect(wrapper.emitted('update:modelValue')!.pop()).toEqual([100]);
});
test('should not emit change event when value not changed', async () => {
@@ -179,11 +179,11 @@ test('should not emit change event when value not changed', async () => {
const button = wrapper.find('.van-slider__button');
trigger(button, 'touchstart');
trigger(wrapper, 'click', 100, 0);
expect(wrapper.emitted('change').length).toEqual(1);
expect(wrapper.emitted('change')!.length).toEqual(1);
await wrapper.setProps({ modelValue: 100 });
trigger(button, 'touchstart');
trigger(wrapper, 'click', 100, 0);
expect(wrapper.emitted('change').length).toEqual(1);
expect(wrapper.emitted('change')!.length).toEqual(1);
});
+24 -23
View File
@@ -30,8 +30,8 @@ test('should emit minus event when clicking the minus button', async () => {
expect(wrapper.emitted('overlimit')).toBeFalsy();
expect(wrapper.emitted('minus')).toBeTruthy();
expect(wrapper.emitted('change')[0]).toEqual([1, { name: '' }]);
expect(wrapper.emitted('update:modelValue')[0]).toEqual([1]);
expect(wrapper.emitted('change')![0]).toEqual([1, { name: '' }]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([1]);
});
test('should emit plus event when clicking the plus button', async () => {
@@ -45,8 +45,8 @@ test('should emit plus event when clicking the plus button', async () => {
expect(wrapper.emitted('overlimit')).toBeFalsy();
expect(wrapper.emitted('plus')).toBeTruthy();
expect(wrapper.emitted('change')[0]).toEqual([3, { name: '' }]);
expect(wrapper.emitted('update:modelValue')[0]).toEqual([3]);
expect(wrapper.emitted('change')![0]).toEqual([3, { name: '' }]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([3]);
});
test('should emit overlimit event when clicking disabled buttons', async () => {
@@ -59,11 +59,11 @@ test('should emit overlimit event when clicking disabled buttons', async () => {
const minus = wrapper.find('.van-stepper__minus');
await minus.trigger('click');
expect(wrapper.emitted('overlimit')[0]).toEqual(['minus']);
expect(wrapper.emitted('overlimit')![0]).toEqual(['minus']);
const plus = wrapper.find('.van-stepper__plus');
await plus.trigger('click');
expect(wrapper.emitted('overlimit')[1]).toEqual(['plus']);
expect(wrapper.emitted('overlimit')![1]).toEqual(['plus']);
});
test('should disable plus button when disable-plus prop is true', async () => {
@@ -122,7 +122,7 @@ test('should update value after long pressing', async () => {
await plus.trigger('touchstart');
await plus.trigger('touchend');
await plus.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([2]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([2]);
await plus.trigger('touchstart');
await later(1000);
@@ -157,17 +157,17 @@ test('should filter invalid value during user input', async () => {
const inputEl = input.element as HTMLInputElement;
inputEl.value = '';
await input.trigger('input');
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['']);
expect(wrapper.emitted('update:modelValue')![0]).toEqual(['']);
inputEl.value = 'a';
await input.trigger('input');
expect(inputEl.value).toEqual('');
expect(wrapper.emitted('update:modelValue')[1]).toBeFalsy();
expect(wrapper.emitted('update:modelValue')![1]).toBeFalsy();
inputEl.value = '2';
await input.trigger('input');
expect(inputEl.value).toEqual('2');
expect(wrapper.emitted('update:modelValue')[1]).toEqual([2]);
expect(wrapper.emitted('update:modelValue')![1]).toEqual([2]);
});
test('shoud watch modelValue and format it', async () => {
@@ -179,7 +179,7 @@ test('shoud watch modelValue and format it', async () => {
});
await wrapper.setProps({ modelValue: 10 });
expect(wrapper.emitted('update:modelValue')[0]).toEqual([5]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([5]);
});
test('should format value to integer when using integer prop', async () => {
@@ -195,7 +195,7 @@ test('should format value to integer when using integer prop', async () => {
await input.trigger('input');
await input.trigger('blur');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([2]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([2]);
});
test('should format value to default value when input is invalid', async () => {
@@ -210,7 +210,7 @@ test('should format value to default value when input is invalid', async () => {
await input.trigger('input');
await input.trigger('blur');
expect(wrapper.emitted('update:modelValue').pop()).toEqual([1]);
expect(wrapper.emitted('update:modelValue')!.pop()).toEqual([1]);
});
test('should emit focus event when input is focused', async () => {
@@ -240,10 +240,10 @@ test('should format input value when stepper blured', async () => {
const input = wrapper.find('input');
input.element.value = '';
await input.trigger('input');
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['']);
expect(wrapper.emitted('update:modelValue')![0]).toEqual(['']);
await input.trigger('blur');
expect(wrapper.emitted('update:modelValue')[1]).toEqual([3]);
expect(wrapper.emitted('update:modelValue')![1]).toEqual([3]);
expect(wrapper.emitted('blur')).toBeTruthy();
});
@@ -332,8 +332,9 @@ test('should limit dicimal length when using decimal-length prop', async () => {
},
});
const plus = wrapper.find('.van-stepper__plus');
expect(wrapper.emitted('update:modelValue')![0]).toEqual(['1.00']);
await plus.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['1.20']);
expect(wrapper.emitted('update:modelValue')![1]).toEqual(['1.20']);
});
test('should limit decimal-length when inputing', async () => {
@@ -357,11 +358,11 @@ test('should emit change event with name when using name prop', async () => {
const plus = wrapper.find('.van-stepper__plus');
await plus.trigger('click');
expect(wrapper.emitted('change')[0]).toEqual([2, { name: '' }]);
expect(wrapper.emitted('change')![0]).toEqual([2, { name: '' }]);
await wrapper.setProps({ name: 'name' });
await plus.trigger('click');
expect(wrapper.emitted('change')[1]).toEqual([3, { name: 'name' }]);
expect(wrapper.emitted('change')![1]).toEqual([3, { name: 'name' }]);
});
test('should watch min and max props and format modelValue', async () => {
@@ -372,13 +373,13 @@ test('should watch min and max props and format modelValue', async () => {
});
await wrapper.setProps({ min: 10 });
expect(wrapper.emitted('update:modelValue')[0]).toEqual([10]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([10]);
await wrapper.setProps({
min: 3,
max: 8,
});
expect(wrapper.emitted('update:modelValue')[1]).toEqual([8]);
expect(wrapper.emitted('update:modelValue')![1]).toEqual([8]);
});
test('should watch decimal-length prop and format modelValue', async () => {
@@ -388,7 +389,7 @@ test('should watch decimal-length prop and format modelValue', async () => {
},
});
await wrapper.setProps({ decimalLength: 1 });
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['1.3']);
expect(wrapper.emitted('update:modelValue')![0]).toEqual(['1.3']);
});
test('should watch integer prop and format modelValue', async () => {
@@ -398,7 +399,7 @@ test('should watch integer prop and format modelValue', async () => {
},
});
await wrapper.setProps({ integer: true });
expect(wrapper.emitted('update:modelValue')[0]).toEqual([1]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([1]);
});
test('should render placeholder correctly', () => {
@@ -425,5 +426,5 @@ test('should allow input be to empty when using allow-empty prop', async () => {
await wrapper.setProps({ allowEmpty: false });
await input.trigger('blur');
expect(wrapper.emitted('update:modelValue')[0]).toEqual([1]);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([1]);
});
+1 -1
View File
@@ -5,7 +5,7 @@ test('should emit submit event when submit button is clicked', () => {
const wrapper = mount(SubmitBar);
const button = wrapper.find('.van-submit-bar__button');
button.trigger('click');
expect(wrapper.emitted('submit').length).toEqual(1);
expect(wrapper.emitted('submit')!.length).toEqual(1);
});
test('should render disabled submit button correctly', () => {
+9 -9
View File
@@ -5,26 +5,26 @@ test('should emit update:modelValue event when click the switch button', async (
const wrapper = mount(Switch);
wrapper.trigger('click');
expect(wrapper.emitted('update:modelValue').length).toEqual(1);
expect(wrapper.emitted('update:modelValue')[0]).toEqual([true]);
expect(wrapper.emitted('update:modelValue')!.length).toEqual(1);
expect(wrapper.emitted('update:modelValue')![0]).toEqual([true]);
await wrapper.setProps({ modelValue: true });
wrapper.trigger('click');
expect(wrapper.emitted('update:modelValue').length).toEqual(2);
expect(wrapper.emitted('update:modelValue')[1]).toEqual([false]);
expect(wrapper.emitted('update:modelValue')!.length).toEqual(2);
expect(wrapper.emitted('update:modelValue')![1]).toEqual([false]);
});
test('should emit change event when click the switch button', async () => {
const wrapper = mount(Switch);
wrapper.trigger('click');
expect(wrapper.emitted('change').length).toEqual(1);
expect(wrapper.emitted('change')[0]).toEqual([true]);
expect(wrapper.emitted('change')!.length).toEqual(1);
expect(wrapper.emitted('change')![0]).toEqual([true]);
await wrapper.setProps({ modelValue: true });
wrapper.trigger('click');
expect(wrapper.emitted('change').length).toEqual(2);
expect(wrapper.emitted('change')[1]).toEqual([false]);
expect(wrapper.emitted('change')!.length).toEqual(2);
expect(wrapper.emitted('change')![1]).toEqual([false]);
});
test('should not emit change event or update:modelValue event if disabled', async () => {
@@ -107,5 +107,5 @@ test('should allow to custom active-value and inactive-value', () => {
expect(wrapper.find('.van-switch--on').exists()).toBeTruthy();
wrapper.trigger('click');
expect(wrapper.emitted('update:modelValue')[0]).toEqual(['off']);
expect(wrapper.emitted('update:modelValue')![0]).toEqual(['off']);
});
+1 -1
View File
@@ -9,7 +9,7 @@ test('should emit close event when clicking the close icon', () => {
});
wrapper.find('.van-tag__close').trigger('click');
expect(wrapper.emitted('close').length).toEqual(1);
expect(wrapper.emitted('close')!.length).toEqual(1);
});
test('should hide tag when the show prop is false', () => {
+2 -2
View File
@@ -25,7 +25,7 @@ test('should close Toast when using closeOnClick prop and clicked', () => {
});
wrapper.find('.van-toast').trigger('click');
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
});
test('should close Toast when using closeOnClickOverlay prop and overlay is clicked', () => {
@@ -37,5 +37,5 @@ test('should close Toast when using closeOnClickOverlay prop and overlay is clic
});
wrapper.find('.van-overlay').trigger('click');
expect(wrapper.emitted('update:show')[0]).toEqual([false]);
expect(wrapper.emitted('update:show')![0]).toEqual([false]);
});