mirror of
https://github.com/youzan/vant.git
synced 2025-10-17 16:44:21 +00:00
test(Stepper): reduce test run time (#13421)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { nextTick } from 'vue';
|
import { nextTick } from 'vue';
|
||||||
import { Stepper } from '..';
|
import { Stepper } from '..';
|
||||||
import { mount, later } from '../../../test';
|
import { mount } from '../../../test';
|
||||||
import { LONG_PRESS_START_TIME } from '../../utils';
|
import { LONG_PRESS_START_TIME } from '../../utils';
|
||||||
|
|
||||||
test('should disable buttons and input when using disabled prop', () => {
|
test('should disable buttons and input when using disabled prop', () => {
|
||||||
@@ -113,6 +113,7 @@ test('should limit max value when using max prop', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should update value after long pressing', async () => {
|
test('should update value after long pressing', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
const wrapper = mount(Stepper, {
|
const wrapper = mount(Stepper, {
|
||||||
props: {
|
props: {
|
||||||
modelValue: 1,
|
modelValue: 1,
|
||||||
@@ -127,12 +128,14 @@ test('should update value after long pressing', async () => {
|
|||||||
expect(wrapper.emitted('update:modelValue')![0]).toEqual([2]);
|
expect(wrapper.emitted('update:modelValue')![0]).toEqual([2]);
|
||||||
|
|
||||||
await plus.trigger('touchstart');
|
await plus.trigger('touchstart');
|
||||||
await later(LONG_PRESS_START_TIME + 500);
|
await vi.advanceTimersByTimeAsync(LONG_PRESS_START_TIME + 500);
|
||||||
await plus.trigger('touchend');
|
await plus.trigger('touchend');
|
||||||
expect(wrapper.emitted('update:modelValue')).toEqual([[2], [3], [4], [5]]);
|
expect(wrapper.emitted('update:modelValue')).toEqual([[2], [3], [4], [5]]);
|
||||||
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should allow to disable long press', async () => {
|
test('should allow to disable long press', async () => {
|
||||||
|
vi.useFakeTimers();
|
||||||
const wrapper = mount(Stepper, {
|
const wrapper = mount(Stepper, {
|
||||||
props: {
|
props: {
|
||||||
longPress: false,
|
longPress: false,
|
||||||
@@ -142,10 +145,11 @@ test('should allow to disable long press', async () => {
|
|||||||
|
|
||||||
const plus = wrapper.find('.van-stepper__plus');
|
const plus = wrapper.find('.van-stepper__plus');
|
||||||
await plus.trigger('touchstart');
|
await plus.trigger('touchstart');
|
||||||
await later(800);
|
await vi.advanceTimersByTimeAsync(LONG_PRESS_START_TIME + 500);
|
||||||
await plus.trigger('touchend');
|
await plus.trigger('touchend');
|
||||||
|
|
||||||
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
|
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
|
||||||
|
vi.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should filter invalid value during user input', async () => {
|
test('should filter invalid value during user input', async () => {
|
||||||
|
Reference in New Issue
Block a user