From 46afe5da87e3cfeec0596252942b326177b0cc7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=AA=E8=A7=89=E9=9B=A8=E5=A3=B0?= <544022268@qq.com> Date: Tue, 5 Dec 2023 21:38:42 +0800 Subject: [PATCH] build: update dependencies (#441) * build: update dependencies * style: lint code * chore: update gulp config --- .pnpmfile.cjs | 21 +- common/bem-helper/package.json | 4 +- common/bem-helper/tsconfig.json | 2 +- common/config/package.json | 2 +- common/config/tsconfig.json | 2 +- common/hooks/package.json | 8 +- common/hooks/tsconfig.json | 2 +- common/icons/package.json | 24 +- common/icons/scripts/tsconfig.json | 2 +- common/icons/tsconfig.json | 2 +- common/icons/vite.config.ts | 4 +- common/meta/tsconfig.json | 2 +- common/plugins/package.json | 10 +- common/plugins/scripts/tsconfig.json | 2 +- common/plugins/tsconfig.json | 2 +- common/scripts/package.json | 16 +- common/scripts/scripts/tsconfig.json | 2 +- common/scripts/tsconfig.json | 2 +- common/utils/package.json | 4 +- common/utils/tests/performance.spec.ts | 12 +- common/utils/tsconfig.json | 2 +- .../tests/auto-complete.spec.tsx | 2 +- components/carousel/tests/carousel.spec.tsx | 2 +- .../color-picker/tests/color-picker.spec.tsx | 4 +- .../date-picker/tests/date-picker.spec.tsx | 14 +- .../date-picker/tests/time-picker.spec.tsx | 10 +- components/drawer/tests/drawer.spec.tsx | 4 +- components/dropdown/tests/dropdown.spec.tsx | 10 +- components/ellipsis/tests/ellipsis.spec.tsx | 8 +- components/form/tests/form.spec.tsx | 10 +- components/input/tests/input.spec.tsx | 14 +- components/loading/tests/loading.spec.tsx | 36 +- components/message/message.vue | 4 +- components/modal/tests/modal.spec.tsx | 4 +- .../tests/native-scroll.spec.tsx | 12 +- components/notice/notice.vue | 4 +- .../number-input/tests/number-input.spec.tsx | 14 +- components/scroll/tests/scroll.spec.tsx | 12 +- components/scrollbar/tests/scrollbar.spec.tsx | 5 +- components/slider/tests/slider.spec.tsx | 14 +- components/spin/tests/spin.spec.tsx | 4 +- components/split/tests/split.spec.tsx | 2 +- components/table/tests/table.spec.tsx | 6 +- components/textarea/tests/textarea.spec.tsx | 10 +- components/toast/tests/toast.spec.tsx | 4 +- components/tooltip/tests/tooltip.spec.tsx | 22 +- components/upload/tests/upload.spec.tsx | 2 +- components/viewer/tests/viewer.spec.tsx | 4 +- components/wheel/tests/wheel.spec.tsx | 4 +- dev-server/app.vue | 3 +- dev-server/package.json | 7 +- dev-server/vite.config.ts | 4 +- docs/demos/layout/fit-window/demo.en-US.vue | 2 +- docs/demos/layout/fit-window/demo.zh-CN.vue | 2 +- docs/package.json | 32 +- docs/tsconfig.json | 2 +- gulpfile.ts => gulpfile.mjs | 23 +- package.json | 78 +- playground/package.json | 20 +- playground/tsconfig.json | 2 +- pnpm-lock.yaml | 4461 ++++++++++------- scripts/tsconfig.json | 2 +- style/alert.scss | 2 +- style/badge.scss | 2 +- style/contextmenu.scss | 3 +- style/form.scss | 3 +- style/image.scss | 6 +- style/layout.scss | 12 +- style/linker.scss | 2 +- style/menu.scss | 13 +- style/native-scroll.scss | 4 +- style/number-input.scss | 3 +- style/pagination.scss | 3 +- style/progress.scss | 4 +- style/radio.scss | 4 +- style/row.scss | 3 +- style/scroll.scss | 2 +- style/scrollbar.scss | 5 +- style/slider.scss | 10 +- style/switch.scss | 6 +- style/table.scss | 7 +- style/textarea.scss | 3 +- style/timeline.scss | 25 +- style/tree.scss | 10 +- style/typography.scss | 2 +- style/upload.scss | 7 +- style/wheel.scss | 3 +- 87 files changed, 3004 insertions(+), 2146 deletions(-) rename gulpfile.ts => gulpfile.mjs (67%) diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index 1023e63ae..62f5a09be 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -1,12 +1,17 @@ function readPackage(pkg) { - if (pkg.dependencies.fsevents && pkg.dependencies.fsevents.match(/[\^~]?1./)) { - pkg.dependencies.fsevents = '^2.3.2' - } else if (pkg.dependencies.chokidar && pkg.dependencies.chokidar.match(/[\^~]?2./)) { - pkg.dependencies.chokidar = '^3.5.3' - } else if (pkg.dependencies.micromatch && pkg.dependencies.micromatch.match(/[\^~]?3./)) { - pkg.dependencies.micromatch = '^4.0.5' - } else if (pkg.dependencies.uuid && pkg.dependencies.uuid.match(/[\^~]?3./)) { - pkg.dependencies.uuid = '^7.0.3' + /** @type Record */ + const deps = pkg.dependencies + + if (deps.fsevents && deps.fsevents.match(/[\^~]?1./)) { + deps.fsevents = '^2.3.2' + } else if (deps.chokidar && deps.chokidar.match(/[\^~]?2./)) { + deps.chokidar = '^3.5.3' + } else if (deps.micromatch && deps.micromatch.match(/[\^~]?3./)) { + deps.micromatch = '^4.0.5' + } else if (deps.uuid && deps.uuid.match(/[\^~]?3./)) { + deps.uuid = '^7.0.3' + } else if (deps.loupe && deps.loupe.match(/[\^~]?2\.3\.[0-6]/)) { + deps.loupe = '^2.3.7' } return pkg diff --git a/common/bem-helper/package.json b/common/bem-helper/package.json index f1a824b67..cdec64e22 100644 --- a/common/bem-helper/package.json +++ b/common/bem-helper/package.json @@ -15,9 +15,9 @@ "types": "dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.cjs", + "types": "./dist/index.d.ts", "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" + "require": "./dist/index.cjs" } }, "private": false, diff --git a/common/bem-helper/tsconfig.json b/common/bem-helper/tsconfig.json index 4c2a997f5..3f4e5fc3f 100644 --- a/common/bem-helper/tsconfig.json +++ b/common/bem-helper/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/config/package.json b/common/config/package.json index f5d9cd8eb..6026a6670 100644 --- a/common/config/package.json +++ b/common/config/package.json @@ -33,7 +33,7 @@ "@vexip-ui/utils": "workspace:*" }, "devDependencies": { - "vue": "^3.3.4" + "vue": "^3.3.10" }, "peerDependencies": { "vue": "^3.2.25" diff --git a/common/config/tsconfig.json b/common/config/tsconfig.json index f2b6d4a2d..f95a5b390 100644 --- a/common/config/tsconfig.json +++ b/common/config/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/hooks/package.json b/common/hooks/package.json index 8e2422e79..9d9153937 100644 --- a/common/hooks/package.json +++ b/common/hooks/package.json @@ -15,9 +15,9 @@ "types": "dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "require": "./dist/index.cjs", - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" + "import": "./dist/index.mjs" } }, "private": false, @@ -31,12 +31,12 @@ "directory": "common/hooks" }, "dependencies": { - "@floating-ui/dom": "^1.5.1", + "@floating-ui/dom": "^1.5.3", "@juggle/resize-observer": "^3.4.0", "@vexip-ui/utils": "workspace:*" }, "devDependencies": { - "vue": "^3.3.4" + "vue": "^3.3.10" }, "peerDependencies": { "vue": "^3.2.25" diff --git a/common/hooks/tsconfig.json b/common/hooks/tsconfig.json index f2b6d4a2d..f95a5b390 100644 --- a/common/hooks/tsconfig.json +++ b/common/hooks/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/icons/package.json b/common/icons/package.json index b68585d6f..020a8e828 100644 --- a/common/icons/package.json +++ b/common/icons/package.json @@ -15,12 +15,18 @@ ], "exports": { ".": { + "types": "./types/index.d.ts", "require": "./lib/index.js", - "import": "./es/index.mjs", - "types": "./types/index.d.ts" + "import": "./es/index.mjs" + }, + "./es": { + "types": "./types/index.d.ts", + "import": "./es/index.mjs" + }, + "./lib": { + "types": "./types/index.d.ts", + "require": "./lib/index.js" }, - "./es": "./es/index.mjs", - "./lib": "./lib/index.js", "./es/*.mjs": "./es/*.mjs", "./es/*": "./es/*.mjs", "./lib/*.js": "./lib/*.js", @@ -42,13 +48,13 @@ "directory": "common/icons" }, "devDependencies": { - "@types/node": "^20.8.4", + "@types/node": "^20.10.3", "execa": "^8.0.1", - "fast-glob": "^3.3.1", - "fs-extra": "^11.1.1", + "fast-glob": "^3.3.2", + "fs-extra": "^11.2.0", "kolorist": "^1.8.0", - "prettier": "^3.0.3", - "vue": "^3.3.4" + "prettier": "^3.1.0", + "vue": "^3.3.10" }, "peerDependencies": { "vue": "^3.2.25" diff --git a/common/icons/scripts/tsconfig.json b/common/icons/scripts/tsconfig.json index d205233fe..497797887 100644 --- a/common/icons/scripts/tsconfig.json +++ b/common/icons/scripts/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "noUnusedLocals": true, "resolveJsonModule": true, "esModuleInterop": true, diff --git a/common/icons/tsconfig.json b/common/icons/tsconfig.json index ceac73d48..0343a823b 100644 --- a/common/icons/tsconfig.json +++ b/common/icons/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/icons/vite.config.ts b/common/icons/vite.config.ts index cd8c4735c..3ba303617 100644 --- a/common/icons/vite.config.ts +++ b/common/icons/vite.config.ts @@ -4,7 +4,7 @@ import { readFileSync } from 'node:fs' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' -import type { LogLevel } from 'vite' +import type { LogLevel, UserConfig } from 'vite' const logLevel = process.env.LOG_LEVEL @@ -16,7 +16,7 @@ const externalPkgs = ['@vue'].concat( ) const external = (id: string) => externalPkgs.some(p => p === id || id.startsWith(`${p}/`)) -export default defineConfig(async () => { +export default defineConfig(async (): Promise => { return { logLevel: (logLevel || 'info') as LogLevel, build: { diff --git a/common/meta/tsconfig.json b/common/meta/tsconfig.json index eb00cf903..25c61e17f 100644 --- a/common/meta/tsconfig.json +++ b/common/meta/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/plugins/package.json b/common/plugins/package.json index 1357f0321..0470740bc 100644 --- a/common/plugins/package.json +++ b/common/plugins/package.json @@ -12,9 +12,9 @@ "types": "dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "require": "./dist/index.cjs", - "import": "./dist/index.js", - "types": "./dist/index.d.ts" + "import": "./dist/index.js" } }, "private": false, @@ -33,8 +33,8 @@ "local-pkg": "^0.5.0" }, "devDependencies": { - "@types/node": "^20.4.1", - "tsup": "^7.2.0", - "unplugin-vue-components": "^0.25.2" + "@types/node": "^20.10.3", + "tsup": "^8.0.1", + "unplugin-vue-components": "^0.26.0" } } diff --git a/common/plugins/scripts/tsconfig.json b/common/plugins/scripts/tsconfig.json index d205233fe..497797887 100644 --- a/common/plugins/scripts/tsconfig.json +++ b/common/plugins/scripts/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "noUnusedLocals": true, "resolveJsonModule": true, "esModuleInterop": true, diff --git a/common/plugins/tsconfig.json b/common/plugins/tsconfig.json index 3894f8421..5ac5f6f37 100644 --- a/common/plugins/tsconfig.json +++ b/common/plugins/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/scripts/package.json b/common/scripts/package.json index 0673bbf6a..6ce60f40b 100644 --- a/common/scripts/package.json +++ b/common/scripts/package.json @@ -18,9 +18,9 @@ "types": "dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "require": "./dist/index.cjs", - "import": "./dist/index.js", - "types": "./dist/index.d.ts" + "import": "./dist/index.js" } }, "private": false, @@ -46,11 +46,11 @@ }, "devDependencies": { "@pnpm/types": "^9.4.0", - "@types/minimist": "^1.2.3", - "@types/node": "^20.8.4", - "@types/prompts": "^2.4.6", - "@types/semver": "^7.5.3", - "@types/yargs": "^17.0.29", - "tsup": "^7.2.0" + "@types/minimist": "^1.2.5", + "@types/node": "^20.10.3", + "@types/prompts": "^2.4.9", + "@types/semver": "^7.5.6", + "@types/yargs": "^17.0.32", + "tsup": "^8.0.1" } } diff --git a/common/scripts/scripts/tsconfig.json b/common/scripts/scripts/tsconfig.json index d205233fe..497797887 100644 --- a/common/scripts/scripts/tsconfig.json +++ b/common/scripts/scripts/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "noUnusedLocals": true, "resolveJsonModule": true, "esModuleInterop": true, diff --git a/common/scripts/tsconfig.json b/common/scripts/tsconfig.json index 3894f8421..5ac5f6f37 100644 --- a/common/scripts/tsconfig.json +++ b/common/scripts/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/common/utils/package.json b/common/utils/package.json index a8e8862fd..11fc8a15c 100644 --- a/common/utils/package.json +++ b/common/utils/package.json @@ -15,9 +15,9 @@ "types": "dist/index.d.ts", "exports": { ".": { + "types": "./dist/index.d.ts", "require": "./dist/index.cjs", - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" + "import": "./dist/index.mjs" } }, "private": false, diff --git a/common/utils/tests/performance.spec.ts b/common/utils/tests/performance.spec.ts index eca485447..fa30aa46b 100644 --- a/common/utils/tests/performance.spec.ts +++ b/common/utils/tests/performance.spec.ts @@ -31,7 +31,7 @@ describe('performance', () => { expect(fn).toHaveBeenCalledTimes(1) expect(i).toBe(1) - vi.runAllTimers() + vi.runOnlyPendingTimers() const r3 = dfn() expect(fn).toHaveBeenCalledTimes(1) expect(r2 === r3).toBe(false) @@ -41,7 +41,7 @@ describe('performance', () => { await r1 expect(i).toBe(2) - vi.runAllTimers() + vi.runOnlyPendingTimers() await r3 expect(i).toBe(3) }) @@ -54,7 +54,7 @@ describe('performance', () => { dfn() dfn() expect(fn).toHaveBeenCalledTimes(0) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(fn).toHaveBeenCalledTimes(1) }) @@ -70,7 +70,7 @@ describe('performance', () => { const r2 = dfn() expect(fn).toHaveBeenCalledTimes(0) expect(r1 === r2).toBe(true) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(fn).toHaveBeenCalledTimes(1) expect(i).toBe(1) @@ -82,10 +82,10 @@ describe('performance', () => { expect(fn).toHaveBeenCalledTimes(1) expect(r2 === r3).toBe(false) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(fn).toHaveBeenCalledTimes(2) - vi.runAllTimers() + vi.runOnlyPendingTimers() await r3 expect(i).toBe(3) }) diff --git a/common/utils/tsconfig.json b/common/utils/tsconfig.json index be1716aa0..d86a29f9e 100644 --- a/common/utils/tsconfig.json +++ b/common/utils/tsconfig.json @@ -4,7 +4,7 @@ "module": "esnext", "allowJs": false, "strict": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "skipLibCheck": true, "noUnusedLocals": true, "experimentalDecorators": true, diff --git a/components/auto-complete/tests/auto-complete.spec.tsx b/components/auto-complete/tests/auto-complete.spec.tsx index 22df6c72d..4ed7c925a 100644 --- a/components/auto-complete/tests/auto-complete.spec.tsx +++ b/components/auto-complete/tests/auto-complete.spec.tsx @@ -87,7 +87,7 @@ describe('AutoComplete', () => { const value = OPTIONS[0] emitInput(input, value.toLocaleUpperCase()) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() const selectPopperEl = wrapper.find('.vxp-select__popper') diff --git a/components/carousel/tests/carousel.spec.tsx b/components/carousel/tests/carousel.spec.tsx index 441537815..cdb70db54 100644 --- a/components/carousel/tests/carousel.spec.tsx +++ b/components/carousel/tests/carousel.spec.tsx @@ -14,7 +14,7 @@ async function doTransition(wrapper: VueWrapper) { await nextTick() wrapper.vm.handleAfterMove() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } diff --git a/components/color-picker/tests/color-picker.spec.tsx b/components/color-picker/tests/color-picker.spec.tsx index 63e5be443..9caefd1f4 100644 --- a/components/color-picker/tests/color-picker.spec.tsx +++ b/components/color-picker/tests/color-picker.spec.tsx @@ -35,7 +35,7 @@ async function toggleMove(el: HTMLElement, value = 40) { moveEvent.clientX = value moveEvent.clientY = value document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() const upEvent = new CustomEvent('pointerup') as any @@ -220,7 +220,7 @@ describe('ColorPicker', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-color-picker__selector').classes()).toContain( diff --git a/components/date-picker/tests/date-picker.spec.tsx b/components/date-picker/tests/date-picker.spec.tsx index 80c277fad..ac9a3b9c6 100644 --- a/components/date-picker/tests/date-picker.spec.tsx +++ b/components/date-picker/tests/date-picker.spec.tsx @@ -9,9 +9,9 @@ import { DatePicker } from '..' vi.useFakeTimers() async function runScrollTimers() { - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } @@ -115,6 +115,8 @@ describe('DatePicker', () => { }) it('key toggle visible', async () => { + vi.useRealTimers() + const onEnter = vi.fn() const onCancel = vi.fn() const wrapper = mount(DatePicker, { @@ -145,6 +147,8 @@ describe('DatePicker', () => { await nextFrame() expect(wrapper.classes()).not.toContain('vxp-date-picker--visible') expect(selector.classes()).not.toContain('vxp-date-picker__selector--focused') + + vi.useFakeTimers() }) it('disabled', async () => { @@ -432,7 +436,7 @@ describe('DatePicker', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-date-picker__selector').classes()).toContain( @@ -496,7 +500,9 @@ describe('DatePicker', () => { await wrapper.trigger('click') await wrapper.trigger('clickoutside') expect(wrapper.emitted()).toHaveProperty('update:formatted-value') - expect(wrapper.emitted('update:formatted-value')![0]).toEqual([format(date, valueFormat)]) + expect(wrapper.emitted('update:formatted-value')![0][0]).toMatch( + format(date, 'yyyy-MM-dd HH:mm:') + ) wrapper.unmount() const formatFn = vi.fn(() => '1') diff --git a/components/date-picker/tests/time-picker.spec.tsx b/components/date-picker/tests/time-picker.spec.tsx index 01c17c9af..3b5e78d22 100644 --- a/components/date-picker/tests/time-picker.spec.tsx +++ b/components/date-picker/tests/time-picker.spec.tsx @@ -10,9 +10,9 @@ import { format } from '@vexip-ui/utils' vi.useFakeTimers() async function runScrollTimers() { - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } @@ -92,6 +92,8 @@ describe('TimePicker', () => { }) it('key toggle visible', async () => { + vi.useRealTimers() + const onEnter = vi.fn() const onCancel = vi.fn() const wrapper = mount(TimePicker, { @@ -122,6 +124,8 @@ describe('TimePicker', () => { await nextFrame() expect(wrapper.classes()).not.toContain('vxp-time-picker--visible') expect(selector.classes()).not.toContain('vxp-time-picker__selector--focused') + + vi.useFakeTimers() }) it('popper show', async () => { @@ -329,7 +333,7 @@ describe('TimePicker', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-time-picker__selector').classes()).toContain( diff --git a/components/drawer/tests/drawer.spec.tsx b/components/drawer/tests/drawer.spec.tsx index 9fe109fb4..87f043678 100644 --- a/components/drawer/tests/drawer.spec.tsx +++ b/components/drawer/tests/drawer.spec.tsx @@ -91,7 +91,7 @@ describe('Drawer', () => { }) it('placement', () => { - (['top', 'right', 'bottom', 'left'] as const).forEach(placement => { + ;(['top', 'right', 'bottom', 'left'] as const).forEach(placement => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-drawer__wrapper').classes()).toContain( @@ -140,7 +140,7 @@ describe('Drawer', () => { moveEvent.clientX = 40 moveEvent.clientY = 40 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(onResizeMove).toHaveBeenCalled() expect(onResizeMove).toHaveBeenCalledWith(expect.objectContaining({ width: 160 })) await nextTick() diff --git a/components/dropdown/tests/dropdown.spec.tsx b/components/dropdown/tests/dropdown.spec.tsx index 79833f583..cd340af2f 100644 --- a/components/dropdown/tests/dropdown.spec.tsx +++ b/components/dropdown/tests/dropdown.spec.tsx @@ -75,7 +75,7 @@ describe('Dropdown', () => { expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(false) await wrapper.find('.vxp-dropdown').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-dropdown').classes()).toContain('vxp-dropdown--visible') expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(true) @@ -83,7 +83,7 @@ describe('Dropdown', () => { expect(onToggle).toHaveBeenLastCalledWith(true) await wrapper.find('.vxp-dropdown').trigger('mouseleave') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-dropdown').classes()).not.toContain('vxp-dropdown--visible') expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(false) @@ -161,7 +161,7 @@ describe('Dropdown', () => { expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(false) await wrapper.find('.vxp-dropdown__trigger').trigger('click') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-dropdown').classes()).toContain('vxp-dropdown--visible') expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(true) @@ -169,7 +169,7 @@ describe('Dropdown', () => { expect(onToggle).toHaveBeenLastCalledWith(true) await wrapper.find('.vxp-dropdown__trigger').trigger('click') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-dropdown').classes()).not.toContain('vxp-dropdown--visible') expect(wrapper.find('.vxp-dropdown__popper').exists()).toBe(false) @@ -207,7 +207,7 @@ describe('Dropdown', () => { expect(innerDropdown.exists()).toBe(true) await innerDropdown.trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(innerDropdown.classes()).toContain('vxp-dropdown--visible') expect(onSelect).not.toHaveBeenCalled() diff --git a/components/ellipsis/tests/ellipsis.spec.tsx b/components/ellipsis/tests/ellipsis.spec.tsx index 8466990a0..27bfd5c64 100644 --- a/components/ellipsis/tests/ellipsis.spec.tsx +++ b/components/ellipsis/tests/ellipsis.spec.tsx @@ -47,7 +47,7 @@ describe('Ellipsis', () => { expect(wrapper.findComponent(Ellipsis).vm.visible).toBe(false) wrapper.find('.vxp-ellipsis').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() // expect(wrapper.findComponent(Ellipsis).vm.active).toBe(true) expect(wrapper.findComponent(Ellipsis).vm.visible).toBe(true) @@ -55,7 +55,7 @@ describe('Ellipsis', () => { expect(wrapper.find('.vxp-tooltip__popper').text()).toBe(TEXT) wrapper.find('.vxp-ellipsis').trigger('mouseleave') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.findComponent(Ellipsis).vm.visible).toBe(false) @@ -68,7 +68,7 @@ describe('Ellipsis', () => { expect(wrapper.find('.vxp-ellipsis').classes()).toContain('vxp-ellipsis--multiple') wrapper.find('.vxp-ellipsis').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.findComponent(Ellipsis).vm.visible).toBe(false) @@ -78,7 +78,7 @@ describe('Ellipsis', () => { }) wrapper.find('.vxp-ellipsis').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.findComponent(Ellipsis).vm.visible).toBe(true) }) diff --git a/components/form/tests/form.spec.tsx b/components/form/tests/form.spec.tsx index 2f48e1fa7..856ec4dae 100644 --- a/components/form/tests/form.spec.tsx +++ b/components/form/tests/form.spec.tsx @@ -130,7 +130,7 @@ describe('Form', () => { }) it('label align', () => { - (['right', 'top', 'left'] as const).forEach(align => { + ;(['right', 'top', 'left'] as const).forEach(align => { const wrapper = mount(() => (
@@ -219,10 +219,10 @@ describe('Form', () => { expect(item.find('.vxp-form__help').exists()).toBe(true) await item.find('.vxp-form__help').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(document.querySelector('.vxp-form__help-tip')).toBeTruthy() @@ -245,10 +245,10 @@ describe('Form', () => { expect(item.find('.vxp-form__help').exists()).toBe(true) await item.find('.vxp-form__help').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(document.querySelector('.help')).toBeTruthy() diff --git a/components/input/tests/input.spec.tsx b/components/input/tests/input.spec.tsx index c8bb36a57..0f030a3ab 100644 --- a/components/input/tests/input.spec.tsx +++ b/components/input/tests/input.spec.tsx @@ -128,7 +128,7 @@ describe('Input', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-input').classes()).toContain(`vxp-input--${state}`) @@ -185,7 +185,7 @@ describe('Input', () => { const input = wrapper.find('input').element emitInput(input, TEXT) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalled() }) @@ -203,8 +203,8 @@ describe('Input', () => { const input = wrapper.find('input').element emitInput(input, '2') - vi.runAllTimers() - vi.runAllTimers() + vi.runOnlyPendingTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalledWith(2) @@ -226,7 +226,7 @@ describe('Input', () => { emitInput(input, TEXT) emitInput(input, TEXT) expect(onInput).toHaveBeenCalledTimes(1) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalledTimes(2) }) @@ -246,7 +246,7 @@ describe('Input', () => { expect(onFocus).toHaveBeenCalled() await input.trigger('blur') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.classes()).not.toContain('vxp-input--focused') expect(onBlur).toHaveBeenCalled() @@ -399,7 +399,7 @@ describe('Input', () => { const input = wrapper.find('input').element emitInput(input, TEXT) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.emitted()).toHaveProperty('update:value') expect(wrapper.emitted()['update:value'][0]).toEqual([TEXT]) diff --git a/components/loading/tests/loading.spec.tsx b/components/loading/tests/loading.spec.tsx index bad82cbc7..f97c7a55f 100644 --- a/components/loading/tests/loading.spec.tsx +++ b/components/loading/tests/loading.spec.tsx @@ -7,10 +7,6 @@ import { LoadingManager } from '..' vi.useFakeTimers() -function nextFrame() { - return new Promise(resolve => requestAnimationFrame(resolve)) -} - function createLoading() { const Loading = new LoadingManager() @@ -40,16 +36,13 @@ describe('Loading', () => { const Loading = createLoading() Loading.open({ percent: 0 }) - await nextFrame() - await nextFrame() - vi.runOnlyPendingTimers() - await nextFrame() + await vi.runOnlyPendingTimersAsync() const wrapper = document.querySelector('.vxp-loading')! expect(wrapper).toBeTruthy() const filter = wrapper.querySelector('.vxp-loading__filler') as HTMLElement expect(filter.style.cssText).toMatch(/translateX\(.+\)/) expect(filter.style.cssText).toMatch(/scaleX\(.+\)/) - expect(filter.style.cssText).not.toContain('translateX(0%)') + expect(filter.style.cssText).not.toContain('translateX(-50%)') expect(filter.style.cssText).not.toContain('scaleX(0)') }) @@ -57,10 +50,7 @@ describe('Loading', () => { const Loading = createLoading() Loading.open({ percent: 0, maxPercent: 50 }) - await nextFrame() - await nextFrame() - vi.runAllTimers() - await nextFrame() + await vi.runAllTimersAsync() const wrapper = document.querySelector('.vxp-loading')! expect(wrapper).toBeTruthy() const filter = wrapper.querySelector('.vxp-loading__filler') as HTMLElement @@ -72,20 +62,14 @@ describe('Loading', () => { let wrapper = mount(Loading) wrapper.vm.startLoading({ percent: 0, position: 'top' }) - await nextFrame() - await nextFrame() - vi.runAllTimers() - await nextFrame() + await vi.runAllTimersAsync() expect(wrapper.find('.vxp-loading').attributes('style')).toContain('top: 0px;') wrapper.unmount() wrapper = mount(Loading) wrapper.vm.startLoading({ percent: 0, position: 'bottom' }) - await nextFrame() - await nextFrame() - vi.runAllTimers() - await nextFrame() + await vi.runAllTimersAsync() expect(wrapper.find('.vxp-loading').attributes('style')).toContain('bottom: 0px;') }) @@ -93,10 +77,7 @@ describe('Loading', () => { const wrapper = mount(Loading) wrapper.vm.startLoading({ percent: 0, strokeWidth: 5 }) - await nextFrame() - await nextFrame() - vi.runAllTimers() - await nextFrame() + await vi.runAllTimersAsync() expect(wrapper.find('.vxp-loading').attributes('style')).toContain('height: 5px;') }) @@ -106,10 +87,7 @@ describe('Loading', () => { const wrapper = mount(Loading) wrapper.vm.startLoading({ percent: 0, state }) - await nextFrame() - await nextFrame() - vi.runAllTimers() - await nextFrame() + await vi.runAllTimersAsync() if (state === 'default') { expect(wrapper.find('.vxp-loading').classes()).not.toContain(`vxp-loading--${state}`) diff --git a/components/message/message.vue b/components/message/message.vue index 9f41d11e9..ca75c52ec 100644 --- a/components/message/message.vue +++ b/components/message/message.vue @@ -3,7 +3,7 @@ import { Icon } from '@/components/icon' import { Renderer } from '@/components/renderer' import { Popup } from '@/components/popup' -import { computed, ref, shallowReactive } from 'vue' +import { computed, reactive, ref } from 'vue' import { useIcons, useNameHelper } from '@vexip-ui/config' import { assertiveTypes, effectiveTypes } from './symbol' @@ -46,7 +46,7 @@ function clear() { } defineExpose( - shallowReactive({ + reactive({ popup, add, remove, diff --git a/components/modal/tests/modal.spec.tsx b/components/modal/tests/modal.spec.tsx index 81c6f2cbf..8789b807a 100644 --- a/components/modal/tests/modal.spec.tsx +++ b/components/modal/tests/modal.spec.tsx @@ -201,7 +201,7 @@ describe('Modal', () => { moveEvent.clientX = 40 moveEvent.clientY = 40 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onDragMove).toHaveBeenCalled() expect(onDragMove).toHaveBeenCalledWith(expect.objectContaining({ top: 40, left: 40 })) @@ -257,7 +257,7 @@ describe('Modal', () => { moveEvent.clientX = 80 moveEvent.clientY = 80 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onResizeMove).toHaveBeenCalled() expect(onResizeMove).toHaveBeenCalledWith(expect.objectContaining({ width: 80, height: 80 })) diff --git a/components/native-scroll/tests/native-scroll.spec.tsx b/components/native-scroll/tests/native-scroll.spec.tsx index 51b2cc06e..d863c0c18 100644 --- a/components/native-scroll/tests/native-scroll.spec.tsx +++ b/components/native-scroll/tests/native-scroll.spec.tsx @@ -80,9 +80,9 @@ describe('NativeScroll', () => { set: v => (left = v) }) ;(scroll.vm as any).refresh() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() return scroll @@ -157,9 +157,9 @@ describe('NativeScroll', () => { mockScrollHeight(contentEl, 200) wrapper.vm.refresh() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onXEnabledChange).toHaveBeenCalled() @@ -231,7 +231,7 @@ describe('NativeScroll', () => { autoplay: true }) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(wrapper.vm.y !== 0).toBe(true) }) @@ -284,7 +284,7 @@ describe('NativeScroll', () => { moveEvent.clientX = 20 moveEvent.clientY = 20 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(onBarScroll).toHaveBeenCalled() expect(onBarScroll).toHaveBeenCalledWith(expect.objectContaining({ percentY: 40 })) diff --git a/components/notice/notice.vue b/components/notice/notice.vue index 60c442b3f..59abaa69f 100644 --- a/components/notice/notice.vue +++ b/components/notice/notice.vue @@ -3,7 +3,7 @@ import { Icon } from '@/components/icon' import { Renderer } from '@/components/renderer' import { Popup } from '@/components/popup' -import { computed, ref, shallowReactive } from 'vue' +import { computed, reactive, ref } from 'vue' import { useIcons, useNameHelper } from '@vexip-ui/config' import { assertiveTypes, effectiveTypes } from './symbol' @@ -44,7 +44,7 @@ function config(config: NoticeConfig) { } defineExpose( - shallowReactive({ + reactive({ popup, add, remove, diff --git a/components/number-input/tests/number-input.spec.tsx b/components/number-input/tests/number-input.spec.tsx index 6cbd1bf49..81c1757b4 100644 --- a/components/number-input/tests/number-input.spec.tsx +++ b/components/number-input/tests/number-input.spec.tsx @@ -132,7 +132,7 @@ describe('NumberInput', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-number-input').classes()).toContain(`vxp-number-input--${state}`) @@ -189,7 +189,7 @@ describe('NumberInput', () => { const input = wrapper.find('input').element emitInput(input, NUMBER) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalled() }) @@ -207,7 +207,7 @@ describe('NumberInput', () => { emitInput(input, NUMBER) emitInput(input, NUMBER) expect(onInput).toHaveBeenCalledTimes(1) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalledTimes(2) }) @@ -227,7 +227,7 @@ describe('NumberInput', () => { expect(onFocus).toHaveBeenCalled() await input.trigger('blur') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.classes()).not.toContain('vxp-number-input--focused') expect(onBlur).toHaveBeenCalled() @@ -418,13 +418,13 @@ describe('NumberInput', () => { const input = wrapper.find('input').element emitInput(input, NUMBER) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.emitted()).toHaveProperty('update:value') expect(wrapper.emitted()['update:value'][0]).toEqual([NUMBER]) emitChange(input, NUMBER) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onChange).toHaveBeenCalledWith(NUMBER) }) @@ -445,7 +445,7 @@ describe('NumberInput', () => { expect(onChange).toHaveBeenLastCalledWith(5) emitInput(input, 11) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-number-input').classes()).toContain('vxp-number-input--out-of-range') }) diff --git a/components/scroll/tests/scroll.spec.tsx b/components/scroll/tests/scroll.spec.tsx index bf3efffc3..1d0eaa539 100644 --- a/components/scroll/tests/scroll.spec.tsx +++ b/components/scroll/tests/scroll.spec.tsx @@ -10,9 +10,9 @@ vi.useFakeTimers() const TEXT = 'TEXT' async function runScrollTimers() { - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } @@ -225,12 +225,16 @@ describe('Scroll', () => { }) it('auto play', async () => { + const onScroll = vi.fn() wrapper = createScroll({ mode: 'vertical', - autoplay: true + autoplay: true, + onScroll }) await runScrollTimers() + await runScrollTimers() + expect(onScroll).toHaveBeenCalled() expect(wrapper.vm.y !== 0).toBe(true) }) @@ -285,7 +289,7 @@ describe('Scroll', () => { moveEvent.clientX = 20 moveEvent.clientY = 20 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(onBarScroll).toHaveBeenCalled() expect(onBarScroll).toHaveBeenCalledWith(expect.objectContaining({ percentY: 40 })) diff --git a/components/scrollbar/tests/scrollbar.spec.tsx b/components/scrollbar/tests/scrollbar.spec.tsx index 690fe0e0d..fa0d0bbba 100644 --- a/components/scrollbar/tests/scrollbar.spec.tsx +++ b/components/scrollbar/tests/scrollbar.spec.tsx @@ -114,7 +114,7 @@ describe('Scrollbar', () => { moveEvent.clientX = 40 moveEvent.clientY = 40 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(onScroll).toHaveBeenCalled() expect(onScroll).toHaveBeenCalledWith(50) @@ -128,6 +128,8 @@ describe('Scrollbar', () => { }) it('track', async () => { + vi.useRealTimers() + const onScrollStart = vi.fn() const onScroll = vi.fn() const onScrollEnd = vi.fn() @@ -198,5 +200,6 @@ describe('Scrollbar', () => { trackMock.mockRestore() barMock.mockRestore() + vi.useFakeTimers() }) }) diff --git a/components/slider/tests/slider.spec.tsx b/components/slider/tests/slider.spec.tsx index 203809f60..c0b44052b 100644 --- a/components/slider/tests/slider.spec.tsx +++ b/components/slider/tests/slider.spec.tsx @@ -21,14 +21,14 @@ async function move(value = 40) { moveEvent.clientX = value moveEvent.clientY = value document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } async function moveEnd() { const upEvent = new CustomEvent('pointerup') as any document.dispatchEvent(upEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } @@ -151,7 +151,7 @@ describe('Slider', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-slider').classes()).toContain(`vxp-slider--${state}`) @@ -329,21 +329,21 @@ describe('Slider', () => { expect(wrapper.find('.vxp-slider').classes()).toContain('vxp-slider--hide-trigger') wrapperEl.dispatchEvent(new CustomEvent('pointerenter')) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-slider').classes()).not.toContain('vxp-slider--hide-trigger') await moveStart(wrapperEl, 30) wrapperEl.dispatchEvent(new CustomEvent('pointerleave')) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-slider').classes()).not.toContain('vxp-slider--hide-trigger') wrapperEl.dispatchEvent(new CustomEvent('pointerenter')) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() await moveEnd() wrapperEl.dispatchEvent(new CustomEvent('pointerleave')) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-slider').classes()).toContain('vxp-slider--hide-trigger') }) diff --git a/components/spin/tests/spin.spec.tsx b/components/spin/tests/spin.spec.tsx index e90053b30..843f2eb85 100644 --- a/components/spin/tests/spin.spec.tsx +++ b/components/spin/tests/spin.spec.tsx @@ -42,14 +42,14 @@ describe('Spin', () => { await wrapper.setProps({ active: true }) expect(wrapper.find('.vxp-spin__loading').exists()).toBe(false) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-spin__loading').exists()).toBe(true) await wrapper.setProps({ active: false }) expect(wrapper.find('.vxp-spin__loading').exists()).toBe(true) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-spin__loading').exists()).toBe(false) }) diff --git a/components/split/tests/split.spec.tsx b/components/split/tests/split.spec.tsx index 546dc4a01..2588c88b8 100644 --- a/components/split/tests/split.spec.tsx +++ b/components/split/tests/split.spec.tsx @@ -18,7 +18,7 @@ async function toggleStartAndMove(el: HTMLElement, value = 40) { moveEvent.clientX = value moveEvent.clientY = value document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } diff --git a/components/table/tests/table.spec.tsx b/components/table/tests/table.spec.tsx index 9d5f45a74..e48c9e89b 100644 --- a/components/table/tests/table.spec.tsx +++ b/components/table/tests/table.spec.tsx @@ -17,9 +17,9 @@ vi.useFakeTimers() async function runScrollTimers() { await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } @@ -903,7 +903,7 @@ describe('Table', () => { const moveEvent = new CustomEvent('pointermove') as any moveEvent.clientX = 40 document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() expect(onMove).toHaveBeenCalled() expect(currentWidth).toEqual(140) diff --git a/components/textarea/tests/textarea.spec.tsx b/components/textarea/tests/textarea.spec.tsx index 11925a028..073aac038 100644 --- a/components/textarea/tests/textarea.spec.tsx +++ b/components/textarea/tests/textarea.spec.tsx @@ -58,7 +58,7 @@ describe('Textarea', () => { }) it('state', () => { - (['success', 'warning', 'error'] as const).forEach(state => { + ;(['success', 'warning', 'error'] as const).forEach(state => { const wrapper = mount(() => ) expect(wrapper.find('.vxp-textarea').classes()).toContain(`vxp-textarea--${state}`) @@ -106,7 +106,7 @@ describe('Textarea', () => { const textarea = wrapper.find('textarea').element emitInput(textarea, TEXT) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalled() }) @@ -124,7 +124,7 @@ describe('Textarea', () => { emitInput(textarea, TEXT) emitInput(textarea, TEXT) expect(onInput).toHaveBeenCalledTimes(1) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(onInput).toHaveBeenCalledTimes(2) }) @@ -144,7 +144,7 @@ describe('Textarea', () => { expect(onFocus).toHaveBeenCalled() await textarea.trigger('blur') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.classes()).not.toContain('vxp-textarea--focused') expect(onBlur).toHaveBeenCalled() @@ -191,7 +191,7 @@ describe('Textarea', () => { const textarea = wrapper.find('textarea').element emitInput(textarea, TEXT) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.emitted()).toHaveProperty('update:value') expect(wrapper.emitted()['update:value'][0]).toEqual([TEXT]) diff --git a/components/toast/tests/toast.spec.tsx b/components/toast/tests/toast.spec.tsx index ad2d5b748..c39f415fc 100644 --- a/components/toast/tests/toast.spec.tsx +++ b/components/toast/tests/toast.spec.tsx @@ -63,7 +63,7 @@ describe('Toast', () => { await toastOpened() expect(document.querySelector('.vxp-toast__wrapper')).toBeTruthy() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(document.querySelector('.vxp-toast__wrapper')).toBeFalsy() }) @@ -99,7 +99,7 @@ describe('Toast', () => { document.querySelector('.vxp-toast__wrapper')?.classList.contains('vxp-toast__wrapper--top') ).toBe(true) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() Toast.open({ content: TEXT, diff --git a/components/tooltip/tests/tooltip.spec.tsx b/components/tooltip/tests/tooltip.spec.tsx index 8cf55715f..13d1414d3 100644 --- a/components/tooltip/tests/tooltip.spec.tsx +++ b/components/tooltip/tests/tooltip.spec.tsx @@ -39,7 +39,7 @@ describe('Tooltip', () => { wrapper = createTooltip() await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(true) expect(wrapper.find('.vxp-tooltip__popper').classes()).toContain('vxp-tooltip-vars') @@ -51,7 +51,7 @@ describe('Tooltip', () => { wrapper = createTooltip({ trigger: 'click' }) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(false) @@ -65,7 +65,7 @@ describe('Tooltip', () => { wrapper = createTooltip({ trigger: 'focus' }) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(false) @@ -79,24 +79,24 @@ describe('Tooltip', () => { wrapper = createTooltip({ trigger: 'hover-focus' }) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(true) expect(wrapper.find('.tip').exists()).toBe(true) expect(wrapper.find('.tip').text()).toEqual(TEXT) await wrapper.find('.trigger').trigger('focus') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(true) await wrapper.find('.trigger').trigger('mouseleave') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(true) await wrapper.find('.trigger').trigger('blur') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(false) }) @@ -105,7 +105,7 @@ describe('Tooltip', () => { wrapper = createTooltip({ trigger: 'custom' }) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(false) @@ -121,7 +121,7 @@ describe('Tooltip', () => { expect(wrapper.find('.trigger').exists()).toBe(true) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() await wrapper.setProps({ disabled: true }) expect(wrapper.find('.vxp-tooltip__popper').exists()).toBe(false) @@ -131,10 +131,10 @@ describe('Tooltip', () => { wrapper = createTooltip({ transfer: true }) await wrapper.find('.trigger').trigger('mouseenter') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() expect(document.querySelector('.vxp-tooltip__popper')).not.toBeNull() expect(document.querySelector('.tip')).not.toBeNull() diff --git a/components/upload/tests/upload.spec.tsx b/components/upload/tests/upload.spec.tsx index 66070b5dd..1b060f1de 100644 --- a/components/upload/tests/upload.spec.tsx +++ b/components/upload/tests/upload.spec.tsx @@ -247,7 +247,7 @@ describe('Upload', () => { hasDargOver() await triggerItem.trigger('dragleave') - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() notDragOver() diff --git a/components/viewer/tests/viewer.spec.tsx b/components/viewer/tests/viewer.spec.tsx index 4e32b8ff1..6b2a4c291 100644 --- a/components/viewer/tests/viewer.spec.tsx +++ b/components/viewer/tests/viewer.spec.tsx @@ -19,7 +19,7 @@ async function toggleMove(el: HTMLElement, value = 40) { moveEvent.clientX = value moveEvent.clientY = value document.dispatchEvent(moveEvent) - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() const upEvent = new CustomEvent('pointerup') as any @@ -50,7 +50,7 @@ describe('Viewer', () => { }) it('toolbar placement', () => { - ( + ;( [ 'top', 'top-start', diff --git a/components/wheel/tests/wheel.spec.tsx b/components/wheel/tests/wheel.spec.tsx index 4075ffb6f..032b8f7e1 100644 --- a/components/wheel/tests/wheel.spec.tsx +++ b/components/wheel/tests/wheel.spec.tsx @@ -9,9 +9,9 @@ vi.useFakeTimers() const OPTIONS = Array.from({ length: 20 }, (_, i) => `Option ${i + 1}`) async function runScrollTimers() { - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() - vi.runAllTimers() + vi.runOnlyPendingTimers() await nextTick() } diff --git a/dev-server/app.vue b/dev-server/app.vue index d00650ebb..00a7dcfc8 100644 --- a/dev-server/app.vue +++ b/dev-server/app.vue @@ -142,8 +142,7 @@ body { width: 100%; max-height: calc(100vh - 128px); padding: 20px; - overflow-x: hidden; - overflow-y: auto; + overflow: hidden auto; scrollbar-width: thin; scrollbar-color: var(--vxp-color-primary-opacity-8) transparent; diff --git a/dev-server/package.json b/dev-server/package.json index d178febc8..8fa68d049 100644 --- a/dev-server/package.json +++ b/dev-server/package.json @@ -1,16 +1,17 @@ { "name": "@vexip-ui/dev-server", + "type": "module", "private": true, "scripts": { "serve": "vite" }, "dependencies": { - "vue": "^3.3.4", + "vue": "^3.3.10", "vue-router": "^4.2.5" }, "devDependencies": { "autoprefixer": "^10.4.16", - "postcss": "^8.4.31", - "unplugin-vue-components": "^0.25.2" + "postcss": "^8.4.32", + "unplugin-vue-components": "^0.26.0" } } diff --git a/dev-server/vite.config.ts b/dev-server/vite.config.ts index 6c5878a2e..3074a5e6b 100644 --- a/dev-server/vite.config.ts +++ b/dev-server/vite.config.ts @@ -44,8 +44,8 @@ const typography = [ 'Strong' ] -export default defineConfig(() => { - return { +export default defineConfig((): UserConfig => { + return { publicDir: '../docs/public', define: { __TARGET__: JSON.stringify(target), diff --git a/docs/demos/layout/fit-window/demo.en-US.vue b/docs/demos/layout/fit-window/demo.en-US.vue index dfad9d13e..33bff43c8 100644 --- a/docs/demos/layout/fit-window/demo.en-US.vue +++ b/docs/demos/layout/fit-window/demo.en-US.vue @@ -1,6 +1,6 @@