test(Stepper): reduce test run time (#13421)

This commit is contained in:
inottn
2025-04-07 10:18:57 +08:00
committed by GitHub
parent 6ed3fc817b
commit b9e7801d23

View File

@@ -1,6 +1,6 @@
import { nextTick } from 'vue';
import { Stepper } from '..';
import { mount, later } from '../../../test';
import { mount } from '../../../test';
import { LONG_PRESS_START_TIME } from '../../utils';
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 () => {
vi.useFakeTimers();
const wrapper = mount(Stepper, {
props: {
modelValue: 1,
@@ -127,12 +128,14 @@ test('should update value after long pressing', async () => {
expect(wrapper.emitted('update:modelValue')![0]).toEqual([2]);
await plus.trigger('touchstart');
await later(LONG_PRESS_START_TIME + 500);
await vi.advanceTimersByTimeAsync(LONG_PRESS_START_TIME + 500);
await plus.trigger('touchend');
expect(wrapper.emitted('update:modelValue')).toEqual([[2], [3], [4], [5]]);
vi.useRealTimers();
});
test('should allow to disable long press', async () => {
vi.useFakeTimers();
const wrapper = mount(Stepper, {
props: {
longPress: false,
@@ -142,10 +145,11 @@ test('should allow to disable long press', async () => {
const plus = wrapper.find('.van-stepper__plus');
await plus.trigger('touchstart');
await later(800);
await vi.advanceTimersByTimeAsync(LONG_PRESS_START_TIME + 500);
await plus.trigger('touchend');
expect(wrapper.emitted('update:modelValue')).toBeFalsy();
vi.useRealTimers();
});
test('should filter invalid value during user input', async () => {