diff --git a/packages/vant/src/stepper/test/index.spec.ts b/packages/vant/src/stepper/test/index.spec.ts index 9bdb6e5cb..b9801acf5 100644 --- a/packages/vant/src/stepper/test/index.spec.ts +++ b/packages/vant/src/stepper/test/index.spec.ts @@ -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 () => {