From b9b38e0de904b22d1bee43b50ad99cce269bde52 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 26 Mar 2026 23:05:19 +0800 Subject: [PATCH] test: add back test for custom threshold prop --- .../vant/src/signature/test/index.spec.ts | 10 +-- .../vant/src/swipe-cell/test/index.spec.ts | 21 +++++++ pnpm-lock.yaml | 63 ++++++++++--------- 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/packages/vant/src/signature/test/index.spec.ts b/packages/vant/src/signature/test/index.spec.ts index e911b094d..105e6d64a 100644 --- a/packages/vant/src/signature/test/index.spec.ts +++ b/packages/vant/src/signature/test/index.spec.ts @@ -129,8 +129,8 @@ test('undo should restore canvas to previous state', async () => { const canvas = wrapper.find('canvas'); const ctx = canvas.element.getContext('2d')!; - const putImageDataSpy = vi.spyOn(ctx, 'putImageData'); - const clearRectSpy = vi.spyOn(ctx, 'clearRect'); + const putImageDataSpy = rs.spyOn(ctx, 'putImageData'); + const clearRectSpy = rs.spyOn(ctx, 'clearRect'); // First stroke await canvas.trigger('touchstart'); @@ -165,7 +165,7 @@ test('history should be limited by historySize prop', async () => { const canvas = wrapper.find('canvas'); const ctx = canvas.element.getContext('2d')!; - const getImageDataSpy = vi.spyOn(ctx, 'getImageData'); + const getImageDataSpy = rs.spyOn(ctx, 'getImageData'); // Draw 5 strokes for (let i = 0; i < 5; i++) { @@ -180,7 +180,7 @@ test('history should be limited by historySize prop', async () => { expect(getImageDataSpy).toHaveBeenCalledTimes(5); // Undo 3 times (max history size) - const clearRectSpy = vi.spyOn(ctx, 'clearRect'); + const clearRectSpy = rs.spyOn(ctx, 'clearRect'); wrapper.vm.undo(); wrapper.vm.undo(); wrapper.vm.undo(); @@ -188,7 +188,7 @@ test('history should be limited by historySize prop', async () => { expect(clearRectSpy).toHaveBeenCalledTimes(3); // Fourth undo should do nothing (history exhausted) - const putImageDataSpy = vi.spyOn(ctx, 'putImageData'); + const putImageDataSpy = rs.spyOn(ctx, 'putImageData'); putImageDataSpy.mockClear(); wrapper.vm.undo(); expect(putImageDataSpy).not.toHaveBeenCalled(); diff --git a/packages/vant/src/swipe-cell/test/index.spec.ts b/packages/vant/src/swipe-cell/test/index.spec.ts index 3c19d5c30..8acfbc564 100644 --- a/packages/vant/src/swipe-cell/test/index.spec.ts +++ b/packages/vant/src/swipe-cell/test/index.spec.ts @@ -204,6 +204,27 @@ test('should emit open event when opening right side', () => { }); }); +test('should use custom threshold prop', async () => { + const wrapper = mount(SwipeCell, { + ...defaultProps, + props: { + ...defaultProps.props, + threshold: 0.5, + }, + }); + + triggerDrag(wrapper, 50, 0); + await later(); + + const track = wrapper.find('.van-swipe-cell__wrapper').element; + expect(track.style.transform).toEqual('translate3d(0px, 0, 0)'); + + triggerDrag(wrapper, 60, 0); + await later(); + + expect(track.style.transform).toEqual('translate3d(100px, 0, 0)'); +}); + test('should emit close event after closed', () => { const wrapper = mount(SwipeCell, defaultProps); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7d2c6792a..121d2708d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -225,10 +225,10 @@ importers: version: 4.17.23 markdown-it: specifier: ^14.1.0 - version: 14.1.1 + version: 14.1.0 markdown-it-anchor: specifier: ^9.2.0 - version: 9.2.0(@types/markdown-it@14.1.2)(markdown-it@14.1.1) + version: 9.2.0(@types/markdown-it@14.1.2)(markdown-it@14.1.0) nano-staged: specifier: ^0.9.0 version: 0.9.0 @@ -1887,6 +1887,9 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} + caniuse-lite@1.0.30001761: + resolution: {integrity: sha512-JF9ptu1vP2coz98+5051jZ4PwQgd2ni8A+gYSN7EA7dPKIMf0pDlSUxhdmVOaV3/fYK5uWBkgSXJaRLr4+3A6g==} + caniuse-lite@1.0.30001781: resolution: {integrity: sha512-RdwNCyMsNBftLjW6w01z8bKEvT6e/5tpPVEgtn22TiLGlstHOVecsX2KHFkD5e/vRnIE4EGzpuIODb3mtswtkw==} @@ -2059,8 +2062,8 @@ packages: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} - entities@7.0.1: - resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==} + entities@7.0.0: + resolution: {integrity: sha512-FDWG5cmEYf2Z00IkYRhbFrwIwvdFKH07uV8dvNy0omp/Qb1xcyCWp2UDtcwJF4QZZvk0sLudP6/hAu42TaqVhQ==} engines: {node: '>=0.12'} entities@7.0.1: @@ -2484,8 +2487,8 @@ packages: '@types/markdown-it': '*' markdown-it: '*' - markdown-it@14.1.1: - resolution: {integrity: sha512-BuU2qnTti9YKgK5N+IeMubp14ZUKUUw7yeJbkjtosvHiP0AZ5c8IAgEMk79D0eC8F23r4Ac/q8cAIFdm2FtyoA==} + markdown-it@14.1.0: + resolution: {integrity: sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==} hasBin: true mdurl@2.0.0: @@ -3320,8 +3323,8 @@ snapshots: '@babel/generator@7.28.5': dependencies: - '@babel/parser': 7.29.0 - '@babel/types': 7.29.0 + '@babel/parser': 7.28.6 + '@babel/types': 7.28.6 '@jridgewell/gen-mapping': 0.3.12 '@jridgewell/trace-mapping': 0.3.29 jsesc: 3.0.2 @@ -3344,7 +3347,7 @@ snapshots: '@babel/helper-annotate-as-pure@7.27.1': dependencies: - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 '@babel/helper-annotate-as-pure@7.27.3': dependencies: @@ -3409,7 +3412,7 @@ snapshots: '@babel/helper-member-expression-to-functions@7.27.1': dependencies: - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.28.6 '@babel/types': 7.29.0 transitivePeerDependencies: - supports-color @@ -3424,7 +3427,7 @@ snapshots: '@babel/helper-module-imports@7.25.9': dependencies: '@babel/traverse': 7.28.6 - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 transitivePeerDependencies: - supports-color @@ -3484,7 +3487,7 @@ snapshots: '@babel/core': 7.27.1 '@babel/helper-member-expression-to-functions': 7.28.5 '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.28.6 transitivePeerDependencies: - supports-color @@ -3493,7 +3496,7 @@ snapshots: '@babel/core': 7.29.0 '@babel/helper-member-expression-to-functions': 7.28.5 '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/traverse': 7.29.0 + '@babel/traverse': 7.28.6 transitivePeerDependencies: - supports-color @@ -3509,7 +3512,7 @@ snapshots: '@babel/helper-skip-transparent-expression-wrappers@7.27.1': dependencies: '@babel/traverse': 7.28.6 - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 transitivePeerDependencies: - supports-color @@ -3524,7 +3527,7 @@ snapshots: '@babel/helpers@7.28.4': dependencies: '@babel/template': 7.28.6 - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 '@babel/helpers@7.28.6': dependencies: @@ -3533,7 +3536,7 @@ snapshots: '@babel/parser@7.28.5': dependencies: - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 '@babel/parser@7.28.6': dependencies: @@ -3564,7 +3567,7 @@ snapshots: '@babel/plugin-syntax-jsx@7.25.9(@babel/core@7.27.1)': dependencies: '@babel/core': 7.27.1 - '@babel/helper-plugin-utils': 7.28.6 + '@babel/helper-plugin-utils': 7.27.1 '@babel/plugin-syntax-jsx@7.27.1(@babel/core@7.29.0)': dependencies: @@ -3574,12 +3577,12 @@ snapshots: '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.27.1)': dependencies: '@babel/core': 7.27.1 - '@babel/helper-plugin-utils': 7.28.6 + '@babel/helper-plugin-utils': 7.27.1 '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.29.0)': dependencies: '@babel/core': 7.29.0 - '@babel/helper-plugin-utils': 7.28.6 + '@babel/helper-plugin-utils': 7.27.1 '@babel/plugin-transform-class-properties@7.28.6(@babel/core@7.29.0)': dependencies: @@ -3659,9 +3662,9 @@ snapshots: '@babel/code-frame': 7.28.6 '@babel/generator': 7.28.6 '@babel/helper-globals': 7.28.0 - '@babel/parser': 7.29.0 + '@babel/parser': 7.28.6 '@babel/template': 7.28.6 - '@babel/types': 7.29.0 + '@babel/types': 7.28.6 debug: 4.4.1 transitivePeerDependencies: - supports-color @@ -4605,8 +4608,8 @@ snapshots: '@babel/code-frame': 7.28.6 '@babel/core': 7.27.1 '@babel/helper-module-imports': 7.27.1 - '@babel/helper-plugin-utils': 7.28.6 - '@babel/parser': 7.29.0 + '@babel/helper-plugin-utils': 7.27.1 + '@babel/parser': 7.28.6 '@vue/compiler-sfc': 3.5.26 transitivePeerDependencies: - supports-color @@ -4637,7 +4640,7 @@ snapshots: dependencies: '@babel/parser': 7.29.0 '@vue/shared': 3.5.26 - entities: 7.0.1 + entities: 7.0.0 estree-walker: 2.0.2 source-map-js: 1.2.1 @@ -4813,7 +4816,7 @@ snapshots: browserslist@4.28.1: dependencies: baseline-browser-mapping: 2.9.11 - caniuse-lite: 1.0.30001781 + caniuse-lite: 1.0.30001761 electron-to-chromium: 1.5.267 node-releases: 2.0.27 update-browserslist-db: 1.2.3(browserslist@4.28.1) @@ -4822,6 +4825,8 @@ snapshots: callsites@3.1.0: {} + caniuse-lite@1.0.30001761: {} + caniuse-lite@1.0.30001781: {} chalk@4.1.2: @@ -4967,7 +4972,7 @@ snapshots: entities@4.5.0: {} - entities@7.0.1: {} + entities@7.0.0: {} entities@7.0.1: {} @@ -5485,12 +5490,12 @@ snapshots: dependencies: semver: 7.6.3 - markdown-it-anchor@9.2.0(@types/markdown-it@14.1.2)(markdown-it@14.1.1): + markdown-it-anchor@9.2.0(@types/markdown-it@14.1.2)(markdown-it@14.1.0): dependencies: '@types/markdown-it': 14.1.2 - markdown-it: 14.1.1 + markdown-it: 14.1.0 - markdown-it@14.1.1: + markdown-it@14.1.0: dependencies: argparse: 2.0.1 entities: 4.5.0