From e81feab987b60b21e35263127adcc34e78db723e Mon Sep 17 00:00:00 2001 From: eiinu Date: Mon, 11 Mar 2024 14:04:38 +0800 Subject: [PATCH] test(address): update --- .../__snapshots__/address.spec.ts.snap | 62 ------------------- .../__VUE/address/__tests__/address.spec.ts | 10 +-- 2 files changed, 3 insertions(+), 69 deletions(-) delete mode 100644 src/packages/__VUE/address/__tests__/__snapshots__/address.spec.ts.snap diff --git a/src/packages/__VUE/address/__tests__/__snapshots__/address.spec.ts.snap b/src/packages/__VUE/address/__tests__/__snapshots__/address.spec.ts.snap deleted file mode 100644 index 2c661101ca..0000000000 --- a/src/packages/__VUE/address/__tests__/__snapshots__/address.spec.ts.snap +++ /dev/null @@ -1,62 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`Address: choose address item 1`] = ` -" - - - - - - - - - 请选择所在地区 - - - - - - - - 请选择 - - - - -
    -
  • -
    - 北京 -
    -
  • -
  • -
    - 广西 -
    -
  • -
  • -
    - 江西 -
    -
  • -
  • -
    - 四川 -
    -
  • -
  • -
    - 浙江 -
    -
  • -
-
-
-
- -
-
-
" -`; diff --git a/src/packages/__VUE/address/__tests__/address.spec.ts b/src/packages/__VUE/address/__tests__/address.spec.ts index 66327c39b9..90449942c1 100644 --- a/src/packages/__VUE/address/__tests__/address.spec.ts +++ b/src/packages/__VUE/address/__tests__/address.spec.ts @@ -2,9 +2,6 @@ import { mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import Address from '../index.vue'; import { addressListData, addressExistData } from '../address-list'; -import { mockElementMethod, sleep } from '@/packages/utils/unit'; - -mockElementMethod(Element, 'scrollTo'); test('Address: address render', async () => { const wrapper = mount(Address, { @@ -36,12 +33,11 @@ test('Address: choose address item', async () => { } } }); - const fn = mockElementMethod(Element, 'scrollTo'); - expect(wrapper.html()).toMatchSnapshot(); expect(wrapper.find('.nut-address__region-item').text()).toEqual('请选择'); + expect(wrapper.findAll('.nut-address__region-item').length).toEqual(1); wrapper.find('.nut-address__detail-item').trigger('click'); - await sleep(0); - expect(fn).toBeCalled(); + await nextTick(); + expect(wrapper.findAll('.nut-address__detail-item.active').length).toEqual(1); }); test('Address: default choose address', async () => {