From 1979fd7bf49a9a73c5b7f90c72245410ff8da028 Mon Sep 17 00:00:00 2001 From: Kael Date: Tue, 3 Sep 2024 22:56:09 +1000 Subject: [PATCH] chore: replace jest with vitest --- .github/workflows/ci.yml | 14 +- .pnpmfile.cjs | 4 + eslint-local-rules.js | 2 +- package.json | 8 +- packages/vuetify/.eslintrc.js | 2 +- packages/vuetify/dev/vuetify.js | 6 +- packages/vuetify/dev/vuetify/icons.js | 6 +- packages/vuetify/dev/vuetify/locale.js | 2 +- packages/vuetify/jest.config.js | 10 - packages/vuetify/package.json | 12 +- .../vuetify/src/__tests__/framework.spec.ts | 2 +- packages/vuetify/src/auto-imports.d.ts | 17 + packages/vuetify/src/components.d.ts | 13 + .../VColorPicker/util/__tests__/index.spec.ts | 2 +- .../VDataTable/__tests__/VDataTable.spec.ts | 2 +- .../VDataTable/__tests__/headers.spec.ts | 5 +- .../VDataTable/__tests__/sort.spec.ts | 2 +- .../__tests__/VDatePicker.date.spec.ts | 2 +- .../createNativeLocaleFormatter.spec.ts | 30 - .../util/__tests__/monthChange.spec.ts | 13 - .../VDatePicker/util/__tests__/pad.spec.ts | 21 - .../util/__tests__/sanitizeDateString.spec.ts | 12 - .../util/createNativeLocaleFormatter.ts | 43 - .../VDatePicker/util/eventHelpers.ts | 24 - .../src/components/VDatePicker/util/index.ts | 20 - .../VDatePicker/util/isDateAllowed.ts | 10 - .../VDatePicker/util/monthChange.ts | 20 - .../src/components/VDatePicker/util/pad.ts | 19 - .../VDatePicker/util/sanitizeDateString.ts | 8 - .../VFileInput/__tests__/VFileInput.spec.tsx | 10 +- .../components/VGrid/__tests__/VCol.spec.ts | 2 +- .../VItemGroup/__tests__/VItemGroup.spec.ts | 4 +- .../__snapshots__/VItemGroup.spec.ts.snap | 9 +- .../components/VList/__tests__/VList.spec.ts | 2 +- .../VList/__tests__/VListItemMedia.spec.ts | 2 +- .../__snapshots__/VList.spec.ts.snap | 10 +- .../__snapshots__/VListItemMedia.spec.ts.snap | 7 +- .../components/VMenu/__tests__/VMenu.spec.ts | 2 +- .../VResponsive/__tests__/VResponsive.spec.ts | 2 +- .../__snapshots__/VResponsive.spec.ts.snap | 42 +- .../__tests__/VSelectionControl.spec.tsx | 6 +- .../VTextField/__tests__/VTextField.spec.tsx | 10 +- .../VTextarea/__tests__/VTextarea.spec.tsx | 10 +- .../__snapshots__/group.spec.ts.snap | 96 +- .../__snapshots__/theme.spec.ts.snap | 6 +- .../src/composables/__tests__/border.spec.ts | 2 +- .../src/composables/__tests__/color.spec.ts | 2 +- .../composables/__tests__/defaults.spec.ts | 2 +- .../src/composables/__tests__/delay.spec.ts | 10 +- .../composables/__tests__/dimensions.spec.ts | 2 +- .../src/composables/__tests__/display.spec.ts | 6 +- .../composables/__tests__/elevation.spec.ts | 4 +- .../src/composables/__tests__/filter.spec.ts | 2 +- .../__tests__/forwardRefs.spec.tsx | 2 +- .../src/composables/__tests__/group.spec.ts | 5 +- .../src/composables/__tests__/icons.spec.ts | 2 +- .../src/composables/__tests__/items.spec.ts | 2 +- .../src/composables/__tests__/loader.spec.ts | 2 +- .../composables/__tests__/location.spec.ts | 2 +- .../__tests__/mutationObserver.spec.ts | 6 +- .../composables/__tests__/position.spec.ts | 2 +- .../__tests__/proxiedModel.spec.ts | 2 +- .../__tests__/resizeObserver.spec.ts | 4 +- .../src/composables/__tests__/rounded.spec.ts | 2 +- .../src/composables/__tests__/scroll.spec.ts | 10 +- .../src/composables/__tests__/size.spec.ts | 4 +- .../src/composables/__tests__/tag.spec.ts | 2 +- .../src/composables/__tests__/theme.spec.ts | 2 +- .../composables/__tests__/validation.spec.ts | 2 +- .../src/composables/__tests__/variant.spec.ts | 4 +- .../composables/date/__tests__/date.spec.ts | 2 +- .../date/adapters/__tests__/vuetify.spec.ts | 2 +- .../nested/__tests__/selectStrategies.spec.ts | 2 +- .../click-outside-shadow-dom.spec.ts | 14 +- .../__tests__/click-outside.spec.ts | 10 +- .../intersect/__tests__/intersect.spec.ts | 6 +- .../mutate/__tests__/mutate.spec.ts | 12 +- .../resize/__tests__/resize.spec.ts | 25 +- .../ripple/__tests__/ripple.spec.ts | 17 +- .../scroll/__tests__/scroll.spec.ts | 22 +- .../directives/touch/__tests__/touch.spec.ts | 30 +- packages/vuetify/src/globals.d.ts | 14 +- .../src/labs/VTimePicker/VTimePicker.tsx | 2 +- .../labs/VTimePicker/VTimePickerControls.tsx | 2 +- packages/vuetify/src/labs/VTimePicker/util.ts | 3 + .../src/locale/__tests__/index.spec.ts | 2 +- .../goto/__tests__/easing-patterns.spec.ts | 26 - .../src/services/goto/__tests__/goto.spec.ts | 73 - .../src/services/goto/easing-patterns.ts | 28 - packages/vuetify/src/services/goto/index.ts | 94 - packages/vuetify/src/services/goto/util.ts | 52 - .../src/util/__tests__/colorUtils.spec.ts | 13 +- .../vuetify/src/util/__tests__/dom.spec.ts | 2 +- .../__tests__/getCurrentInstance.spec.tsx | 2 +- .../src/util/__tests__/helpers.spec.ts | 19 +- .../src/util/__tests__/propsFactory.spec.ts | 5 +- .../vuetify/test/util/to-have-been-warned.ts | 19 +- packages/vuetify/tsconfig.dev.json | 5 +- .../{vite.config.mjs => vite.config.mts} | 23 +- packages/vuetify/vitest.config.mts | 39 + pnpm-lock.yaml | 1620 +++++++---------- scripts/rules/sort-imports.js | 2 +- ...al-imports.js => vitest-global-imports.js} | 10 +- tsconfig.json | 2 +- 104 files changed, 997 insertions(+), 1838 deletions(-) delete mode 100644 packages/vuetify/jest.config.js create mode 100644 packages/vuetify/src/auto-imports.d.ts create mode 100644 packages/vuetify/src/components.d.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/__tests__/createNativeLocaleFormatter.spec.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/__tests__/monthChange.spec.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/__tests__/pad.spec.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/__tests__/sanitizeDateString.spec.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/createNativeLocaleFormatter.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/eventHelpers.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/index.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/monthChange.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/pad.ts delete mode 100644 packages/vuetify/src/components/VDatePicker/util/sanitizeDateString.ts create mode 100644 packages/vuetify/src/labs/VTimePicker/util.ts delete mode 100644 packages/vuetify/src/services/goto/__tests__/easing-patterns.spec.ts delete mode 100644 packages/vuetify/src/services/goto/__tests__/goto.spec.ts delete mode 100644 packages/vuetify/src/services/goto/easing-patterns.ts delete mode 100644 packages/vuetify/src/services/goto/index.ts delete mode 100644 packages/vuetify/src/services/goto/util.ts rename packages/vuetify/{vite.config.mjs => vite.config.mts} (85%) create mode 100644 packages/vuetify/vitest.config.mts rename scripts/rules/{jest-global-imports.js => vitest-global-imports.js} (72%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70ae55916d4..02caa559414 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,19 +59,19 @@ jobs: env: SCOPES: ${{ matrix.scopes }} - test-jest: - name: Test (Jest) + test-unit: + name: Test (Unit) needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: ./.github/actions/pnpm-install - - run: pnpm run test:coverage -i + - run: pnpm run test working-directory: ./packages/vuetify - test-cypress: - name: Test (Cypress) + test-e2e: + name: Test (e2e) needs: pre_job if: needs.pre_job.outputs.should_skip != 'true' runs-on: ubuntu-latest @@ -94,7 +94,7 @@ jobs: if-no-files-found: ignore deploy: - needs: [lint, test-jest, test-cypress, build-vuetify] + needs: [lint, test-unit, test-e2e, build-vuetify] runs-on: ubuntu-latest if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v') && github.repository_owner == 'vuetifyjs' steps: @@ -152,7 +152,7 @@ jobs: path: packages/docs/dist publish-docs: - needs: [lint, test-jest, build-docs] + needs: [lint, test-unit, build-docs] runs-on: ubuntu-latest if: github.event_name == 'push' && github.repository_owner == 'vuetifyjs' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/next') steps: diff --git a/.pnpmfile.cjs b/.pnpmfile.cjs index 5ef62d5594e..e7e3c5af05a 100644 --- a/.pnpmfile.cjs +++ b/.pnpmfile.cjs @@ -14,6 +14,10 @@ module.exports = { if (['@rollup/pluginutils', 'rollup-plugin-terser', '@rollup/plugin-replace'].includes(pkg.name)) { pkg.peerDependencies.rollup = '*' } + if (pkg.name === 'brilliant-errors') { + delete pkg.dependencies.bumpp + delete pkg.dependencies.vitest + } return pkg } } diff --git a/eslint-local-rules.js b/eslint-local-rules.js index da775cc19cb..ca3301bfd2b 100644 --- a/eslint-local-rules.js +++ b/eslint-local-rules.js @@ -5,7 +5,7 @@ module.exports = { 'no-components-index': require('./scripts/rules/no-components-index'), 'jsx-condition-key': require('./scripts/rules/jsx-condition-key'), 'jsx-curly-spacing': require('./scripts/rules/jsx-curly-spacing'), - 'jest-global-imports': require('./scripts/rules/jest-global-imports'), + 'vitest-global-imports': require('./scripts/rules/vitest-global-imports'), 'cypress-types-reference': require('./scripts/rules/cypress-types-reference'), 'sort-imports': require('./scripts/rules/sort-imports'), 'no-nullish-coalescing-in-condition': require('./scripts/rules/no-nullish-coalescing-in-condition'), diff --git a/package.json b/package.json index 47897c36a09..5ba44417d02 100755 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "@vue/runtime-dom": "^3.4.27", "@vueuse/head": "^1.3.1", "babel-eslint": "^10.1.0", - "babel-jest": "^28.1.3", "conventional-changelog-cli": "^3.0.0", "conventional-changelog-vuetify": "^1.2.1", "conventional-github-releaser": "^3.1.5", @@ -66,10 +65,6 @@ "glob": "^11.0.0", "husky": "^3.1.0", "inquirer": "^6.5.2", - "jest": "^28.1.3", - "jest-cli": "^28.1.3", - "jest-environment-jsdom": "^28.1.3", - "jest-serializer-html": "^7.1.0", "lerna": "^8.1.7", "magic-string": "^0.30.9", "mkdirp": "^3.0.1", @@ -94,6 +89,9 @@ "pnpm": { "patchedDependencies": { "@mdi/js@7.4.47": "patches/@mdi__js@7.4.47.patch" + }, + "overrides": { + "tough-cookie": "5.0.0-rc.4" } } } diff --git a/packages/vuetify/.eslintrc.js b/packages/vuetify/.eslintrc.js index 544bb482bdb..f2a2419c247 100644 --- a/packages/vuetify/.eslintrc.js +++ b/packages/vuetify/.eslintrc.js @@ -51,7 +51,7 @@ module.exports = { plugins: ['jest'], extends: ['plugin:jest/recommended'], rules: { - 'local-rules/jest-global-imports': 'error', + 'local-rules/vitest-global-imports': 'error', 'no-restricted-imports': 'off', diff --git a/packages/vuetify/dev/vuetify.js b/packages/vuetify/dev/vuetify.js index acb3f99b3cc..38148f5541e 100644 --- a/packages/vuetify/dev/vuetify.js +++ b/packages/vuetify/dev/vuetify.js @@ -1,8 +1,8 @@ import '@mdi/font/css/materialdesignicons.css' -import 'vuetify/src/styles/main.sass' +import '@/styles/main.sass' -import { createVuetify } from 'vuetify/src/framework' -import * as directives from 'vuetify/src/directives' +import { createVuetify } from '@/framework' +import * as directives from '@/directives' import date from './vuetify/date' import defaults from './vuetify/defaults' diff --git a/packages/vuetify/dev/vuetify/icons.js b/packages/vuetify/dev/vuetify/icons.js index e4f68621ac8..81c74f0ac54 100644 --- a/packages/vuetify/dev/vuetify/icons.js +++ b/packages/vuetify/dev/vuetify/icons.js @@ -1,6 +1,6 @@ -import { aliases } from 'vuetify/src/iconsets/mdi-svg' -import { mdi } from 'vuetify/src/iconsets/mdi' -import { fa } from 'vuetify/src/iconsets/fa-svg' +import { aliases } from '@/iconsets/mdi-svg' +import { mdi } from '@/iconsets/mdi' +import { fa } from '@/iconsets/fa-svg' export default { defaultSet: 'mdi', diff --git a/packages/vuetify/dev/vuetify/locale.js b/packages/vuetify/dev/vuetify/locale.js index c3d3e5d6766..acf4e7d7480 100644 --- a/packages/vuetify/dev/vuetify/locale.js +++ b/packages/vuetify/dev/vuetify/locale.js @@ -1,4 +1,4 @@ -import { ar, en, ja, sv } from 'vuetify/src/locale' +import { ar, en, ja, sv } from '@/locale' export default { messages: { diff --git a/packages/vuetify/jest.config.js b/packages/vuetify/jest.config.js deleted file mode 100644 index 1b4261219f3..00000000000 --- a/packages/vuetify/jest.config.js +++ /dev/null @@ -1,10 +0,0 @@ -const base = require('../../jest.config') - -module.exports = { - ...base, - id: 'Vuetify', - displayName: 'Vuetify', - setupFiles: [ - 'jest-canvas-mock', - ], -} diff --git a/packages/vuetify/package.json b/packages/vuetify/package.json index 618ebff3b14..8def3ada4c8 100755 --- a/packages/vuetify/package.json +++ b/packages/vuetify/package.json @@ -108,10 +108,7 @@ "build:lib": "NODE_ENV=lib babel src --out-dir lib --source-maps --extensions \".ts\",\".tsx\",\".snap\" --copy-files --no-copy-ignored --out-file-extension .mjs", "build:types": "rimraf types-temp && tsc --pretty --emitDeclarationOnly -p tsconfig.dist.json && rollup --config build/rollup.types.config.mjs && rimraf types-temp", "tsc": "tsc", - "debug:test": "NODE_ENV=test node --inspect --inspect-brk ../../node_modules/jest/bin/jest.js --no-cache -i --verbose", - "test": "node build/run-tests.js", - "test:unix": "NODE_ENV=test jest", - "test:win32": "NODE_ENV=test jest -i", + "test": "vitest", "test:coverage": "pnpm run test --coverage", "lint": "concurrently -n \"tsc,eslint\" --kill-others-on-fail \"tsc -p tsconfig.checks.json --noEmit --pretty\" \"eslint src -f codeframe --max-warnings 0\"", "lint:fix": "concurrently -n \"tsc,eslint\" \"tsc -p tsconfig.checks.json --noEmit --pretty\" \"eslint --fix src\"", @@ -126,18 +123,17 @@ "@fortawesome/fontawesome-svg-core": "^6.5.2", "@fortawesome/free-solid-svg-icons": "^6.5.2", "@fortawesome/vue-fontawesome": "^3.0.6", - "@jest/globals": "^28.1.3", "@percy/cli": "^1.28.2", "@percy/cypress": "^3.1.2", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-babel": "^6.0.4", "@rollup/plugin-node-resolve": "^15.2.3", "@rollup/plugin-typescript": "^11.1.6", - "@types/jest": "^28.1.8", "@types/node": "^20.12.7", "@types/resize-observer-browser": "^0.1.11", "@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue-jsx": "^3.1.0", + "@vitest/coverage-v8": "^2.0.5", "@vue/babel-plugin-jsx": "^1.2.2", "@vue/shared": "^3.4.27", "@vue/test-utils": "2.4.6", @@ -161,7 +157,7 @@ "expect": "^28.1.3", "fast-glob": "^3.3.2", "identity-obj-proxy": "^3.0.0", - "jest-canvas-mock": "^2.5.2", + "jsdom": "^25.0.0", "micromatch": "^4.0.5", "postcss": "^8.4.38", "rollup": "^3.20.7", @@ -170,10 +166,12 @@ "rollup-plugin-sourcemaps": "^0.6.3", "rollup-plugin-terser": "^7.0.2", "timezone-mock": "^1.3.6", + "unplugin-auto-import": "0.17.5", "unplugin-vue-components": "^0.27.4", "upath": "^2.0.1", "vite": "^5.4.0", "vite-ssr": "^0.17.1", + "vitest": "^2.0.5", "vue-i18n": "^9.7.1", "vue-router": "^4.3.0" }, diff --git a/packages/vuetify/src/__tests__/framework.spec.ts b/packages/vuetify/src/__tests__/framework.spec.ts index 5ff9ec1cdf3..14031435f5a 100644 --- a/packages/vuetify/src/__tests__/framework.spec.ts +++ b/packages/vuetify/src/__tests__/framework.spec.ts @@ -1,6 +1,6 @@ // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { expect, it } from 'vitest' import { createVuetify } from '@/framework' describe('framework', () => { diff --git a/packages/vuetify/src/auto-imports.d.ts b/packages/vuetify/src/auto-imports.d.ts new file mode 100644 index 00000000000..7e43e9a13f5 --- /dev/null +++ b/packages/vuetify/src/auto-imports.d.ts @@ -0,0 +1,17 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +export {} +declare global { + const afterAll: typeof import('vitest')['afterAll'] + const afterEach: typeof import('vitest')['afterEach'] + const assert: typeof import('vitest')['assert'] + const beforeAll: typeof import('vitest')['beforeAll'] + const beforeEach: typeof import('vitest')['beforeEach'] + const describe: typeof import('vitest')['describe'] + const expect: typeof import('vitest')['expect'] + const it: typeof import('vitest')['it'] + const vi: typeof import('vitest')['vi'] +} diff --git a/packages/vuetify/src/components.d.ts b/packages/vuetify/src/components.d.ts new file mode 100644 index 00000000000..4edc351177c --- /dev/null +++ b/packages/vuetify/src/components.d.ts @@ -0,0 +1,13 @@ +/* eslint-disable */ +// @ts-nocheck +// Generated by unplugin-vue-components +// Read more: https://github.com/vuejs/core/pull/3399 +export {} + +/* prettier-ignore */ +declare module 'vue' { + export interface GlobalComponents { + RouterLink: typeof import('vue-router')['RouterLink'] + RouterView: typeof import('vue-router')['RouterView'] + } +} diff --git a/packages/vuetify/src/components/VColorPicker/util/__tests__/index.spec.ts b/packages/vuetify/src/components/VColorPicker/util/__tests__/index.spec.ts index 972af43efd7..e45f3ef7758 100644 --- a/packages/vuetify/src/components/VColorPicker/util/__tests__/index.spec.ts +++ b/packages/vuetify/src/components/VColorPicker/util/__tests__/index.spec.ts @@ -1,5 +1,5 @@ // Utilities -import { describe, expect, it } from '@jest/globals' +import { expect, it } from 'vitest' import { extractColor } from '../' const red = { h: 0, s: 1, v: 1, a: 1 } diff --git a/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts b/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts index 0e2851aea08..658cb89b15f 100644 --- a/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts +++ b/packages/vuetify/src/components/VDataTable/__tests__/VDataTable.spec.ts @@ -12,7 +12,7 @@ import { // import Vue from 'vue' // import { Lang } from '../../../services/lang' // import { preset } from '../../../presets/default' -// import { resizeWindow } from '../../../../test' +// import { resizeWindow } from '@/../test' // Vue.prototype.$vuetify = { // icons: {}, diff --git a/packages/vuetify/src/components/VDataTable/__tests__/headers.spec.ts b/packages/vuetify/src/components/VDataTable/__tests__/headers.spec.ts index bf5f25a463c..ba5dc1899d1 100644 --- a/packages/vuetify/src/components/VDataTable/__tests__/headers.spec.ts +++ b/packages/vuetify/src/components/VDataTable/__tests__/headers.spec.ts @@ -1,7 +1,6 @@ -import { createHeaders } from '../composables/headers' - // Utilities -import { describe, expect, it } from '@jest/globals' +import { expect, it } from 'vitest' +import { createHeaders } from '../composables/headers' describe('VDataTable headers', () => { it('flattens 2d headers', () => { diff --git a/packages/vuetify/src/components/VDataTable/__tests__/sort.spec.ts b/packages/vuetify/src/components/VDataTable/__tests__/sort.spec.ts index dc5853d6d9a..477aa4e8dc7 100644 --- a/packages/vuetify/src/components/VDataTable/__tests__/sort.spec.ts +++ b/packages/vuetify/src/components/VDataTable/__tests__/sort.spec.ts @@ -4,8 +4,8 @@ import { transformItems as _transformItems } from '../composables/items' import { sortItems as _sortItems } from '../composables/sort' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { expect, it } from 'vitest' // Types import type { SortItem } from '../composables/sort' diff --git a/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts b/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts index 21a70a7eade..00d509fd238 100644 --- a/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts +++ b/packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts @@ -1,7 +1,7 @@ // @ts-nocheck /* eslint-disable */ -// import { touch } from '../../../../test' +// import { touch } from '@/../test' import { mount, MountOptions, diff --git a/packages/vuetify/src/components/VDatePicker/util/__tests__/createNativeLocaleFormatter.spec.ts b/packages/vuetify/src/components/VDatePicker/util/__tests__/createNativeLocaleFormatter.spec.ts deleted file mode 100644 index e39441f95a5..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/__tests__/createNativeLocaleFormatter.spec.ts +++ /dev/null @@ -1,30 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -// import createNativeLocaleFormatter from '../createNativeLocaleFormatter' - -describe.skip('VDatePicker/util/createNativeLocaleFormatter.ts', () => { - it('should format dates', () => { - const formatter = createNativeLocaleFormatter(undefined, { day: 'numeric', timeZone: 'UTC' }) - expect(formatter('2013-2-07')).toBe('7') - }) - - it('should format date with year < 1000', () => { - const formatter = createNativeLocaleFormatter(undefined, { year: 'numeric', timeZone: 'UTC' }) - expect(formatter('13-2-07')).toBe('13') - }) - - it('should format dates if Intl is not defined', () => { - const oldIntl = global.Intl - - global.Intl = null - const formatter = createNativeLocaleFormatter(undefined, { day: 'numeric', timeZone: 'UTC' }, { start: 0, length: 10 }) - expect(formatter('2013-2-7')).toBe('2013-02-07') - expect(formatter('2013-2')).toBe('2013-02-01') - expect(formatter('2013')).toBe('2013-01-01') - - const nullFormatter = createNativeLocaleFormatter(undefined, { day: 'numeric', timeZone: 'UTC' }) - expect(nullFormatter).toBeUndefined() - global.Intl = oldIntl - }) -}) diff --git a/packages/vuetify/src/components/VDatePicker/util/__tests__/monthChange.spec.ts b/packages/vuetify/src/components/VDatePicker/util/__tests__/monthChange.spec.ts deleted file mode 100644 index 8e33d1abb74..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/__tests__/monthChange.spec.ts +++ /dev/null @@ -1,13 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -// import monthChange from '../monthChange' - -describe.skip('VDatePicker/util/monthChange.ts', () => { - it('should change month', () => { - expect(monthChange('2000-01', -1)).toBe('1999-12') - expect(monthChange('2000-01', +1)).toBe('2000-02') - expect(monthChange('2000-12', -1)).toBe('2000-11') - expect(monthChange('2000-12', +1)).toBe('2001-01') - }) -}) diff --git a/packages/vuetify/src/components/VDatePicker/util/__tests__/pad.spec.ts b/packages/vuetify/src/components/VDatePicker/util/__tests__/pad.spec.ts deleted file mode 100644 index 0190093d9d2..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/__tests__/pad.spec.ts +++ /dev/null @@ -1,21 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -// import pad from '../pad' - -describe.skip('VDatePicker/util/pad.ts', () => { - it('should pad 1-digit numbers', () => { - expect(pad(0)).toBe('00') - expect(pad('3', 3)).toBe('003') - }) - - it('should pad 2-digit numbers', () => { - expect(pad(40)).toBe('40') - expect(pad('98')).toBe('98') - }) - - it('should not pad 3-digit numbers', () => { - expect(pad(400)).toBe('400') - expect(pad('998')).toBe('998') - }) -}) diff --git a/packages/vuetify/src/components/VDatePicker/util/__tests__/sanitizeDateString.spec.ts b/packages/vuetify/src/components/VDatePicker/util/__tests__/sanitizeDateString.spec.ts deleted file mode 100644 index 2e688a6c287..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/__tests__/sanitizeDateString.spec.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Utilities -import { describe, expect, it } from '@jest/globals' -import sanitizeDateString from '../sanitizeDateString' - -describe('VDatePicker/util/sanitizeDateString.ts', () => { - it('should sanitize date string based upon type', () => { - expect(sanitizeDateString('2000-01-02T14:48:00.000Z', 'date')).toBe('2000-01-02') - expect(sanitizeDateString('2000-01-02T14:48:00.000Z', 'month')).toBe('2000-01') - expect(sanitizeDateString('2000-01-02T14:48:00.000Z', 'year')).toBe('2000') - expect(sanitizeDateString('2000-1-2', 'date')).toBe('2000-01-02') - }) -}) diff --git a/packages/vuetify/src/components/VDatePicker/util/createNativeLocaleFormatter.ts b/packages/vuetify/src/components/VDatePicker/util/createNativeLocaleFormatter.ts deleted file mode 100644 index d26787ce784..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/createNativeLocaleFormatter.ts +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -import pad from './pad' -import { DatePickerFormatter } from 'vuetify/types' - -interface SubstrOptions { - start?: number - length: number -} - -function createNativeLocaleFormatter ( - local: string | undefined, - options: Intl.DateTimeFormatOptions -): DatePickerFormatter | undefined - -function createNativeLocaleFormatter ( - local: string | undefined, - options: Intl.DateTimeFormatOptions, - substrOptions: SubstrOptions -): DatePickerFormatter - -function createNativeLocaleFormatter ( - locale: string | undefined, - options: Intl.DateTimeFormatOptions, - substrOptions: SubstrOptions = { start: 0, length: 0 } -): DatePickerFormatter | undefined { - const makeIsoString = (dateString: string) => { - const [year, month, date] = dateString.trim().split(' ')[0].split('-') - return [pad(year, 4), pad(month || 1), pad(date || 1)].join('-') - } - - try { - const intlFormatter = new Intl.DateTimeFormat(locale || undefined, options) - return (dateString: string) => intlFormatter.format(new Date(`${makeIsoString(dateString)}T00:00:00+00:00`)) - } catch (e) { - return (substrOptions.start || substrOptions.length) - ? (dateString: string) => makeIsoString(dateString).substr(substrOptions.start || 0, substrOptions.length) - : undefined - } -} - -export default createNativeLocaleFormatter diff --git a/packages/vuetify/src/components/VDatePicker/util/eventHelpers.ts b/packages/vuetify/src/components/VDatePicker/util/eventHelpers.ts deleted file mode 100644 index 9bee354c0a8..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/eventHelpers.ts +++ /dev/null @@ -1,24 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -// import Vue from 'vue' - -export function createItemTypeNativeListeners (instance: /*Vue*/any, itemTypeSuffix: string, value: any) { - return Object.keys(instance.$listeners).reduce((on, eventName) => { - if (eventName.endsWith(itemTypeSuffix)) { - on[eventName.slice(0, -itemTypeSuffix.length)] = (event: Event) => instance.$emit(eventName, value, event) - } - - return on - }, {} as typeof instance.$listeners) -} - -export function createItemTypeListeners (instance: /*Vue*/any, itemTypeSuffix: string) { - return Object.keys(instance.$listeners).reduce((on, eventName) => { - if (eventName.endsWith(itemTypeSuffix)) { - on[eventName] = instance.$listeners[eventName] - } - - return on - }, {} as typeof instance.$listeners) -} diff --git a/packages/vuetify/src/components/VDatePicker/util/index.ts b/packages/vuetify/src/components/VDatePicker/util/index.ts deleted file mode 100644 index c379581d911..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -import { - createItemTypeListeners, - createItemTypeNativeListeners, -} from './eventHelpers' -import createNativeLocaleFormatter from './createNativeLocaleFormatter' -import monthChange from './monthChange' -import sanitizeDateString from './sanitizeDateString' -import pad from './pad' - -export { - createItemTypeListeners, - createItemTypeNativeListeners, - createNativeLocaleFormatter, - monthChange, - sanitizeDateString, - pad, -} diff --git a/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts b/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts deleted file mode 100644 index d1ad1eeaa6b..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/isDateAllowed.ts +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -import { DatePickerAllowedDatesFunction } from 'vuetify/types' - -export default function isDateAllowed (date: string, min: string, max: string, allowedFn: DatePickerAllowedDatesFunction | undefined) { - return (!allowedFn || allowedFn(date)) && - (!min || date >= min.substr(0, 10)) && - (!max || date <= max) -} diff --git a/packages/vuetify/src/components/VDatePicker/util/monthChange.ts b/packages/vuetify/src/components/VDatePicker/util/monthChange.ts deleted file mode 100644 index 178f7fb3741..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/monthChange.ts +++ /dev/null @@ -1,20 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -import pad from './pad' - -/** - * @param {String} value YYYY-MM format - * @param {Number} sign -1 or +1 - */ -export default (value: string, sign: number) => { - const [year, month] = value.split('-').map(Number) - - if (month + sign === 0) { - return `${year - 1}-12` - } else if (month + sign === 13) { - return `${year + 1}-01` - } else { - return `${year}-${pad(month + sign)}` - } -} diff --git a/packages/vuetify/src/components/VDatePicker/util/pad.ts b/packages/vuetify/src/components/VDatePicker/util/pad.ts deleted file mode 100644 index eede14aea94..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/pad.ts +++ /dev/null @@ -1,19 +0,0 @@ -// @ts-nocheck -/* eslint-disable */ - -const padStart = (string: number | string, targetLength: number, padString: string) => { - targetLength = targetLength >> 0 - string = String(string) - padString = String(padString) - if (string.length > targetLength) { - return String(string) - } - - targetLength = targetLength - string.length - if (targetLength > padString.length) { - padString += padString.repeat(targetLength / padString.length) - } - return padString.slice(0, targetLength) + String(string) -} - -export default (n: string | number, length = 2) => padStart(n, length, '0') diff --git a/packages/vuetify/src/components/VDatePicker/util/sanitizeDateString.ts b/packages/vuetify/src/components/VDatePicker/util/sanitizeDateString.ts deleted file mode 100644 index 00e65cdf6dd..00000000000 --- a/packages/vuetify/src/components/VDatePicker/util/sanitizeDateString.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Adds leading zero to month/day if necessary, returns 'YYYY' if type = 'year', -// 'YYYY-MM' if 'month' and 'YYYY-MM-DD' if 'date' -import pad from './pad' - -export default (dateString: string, type: 'date' | 'month' | 'year'): string => { - const [year, month = 1, date = 1] = dateString.split('-') - return `${year}-${pad(month)}-${pad(date)}`.substr(0, { date: 10, month: 7, year: 4 }[type]) -} diff --git a/packages/vuetify/src/components/VFileInput/__tests__/VFileInput.spec.tsx b/packages/vuetify/src/components/VFileInput/__tests__/VFileInput.spec.tsx index 67295922958..0b129da50d4 100644 --- a/packages/vuetify/src/components/VFileInput/__tests__/VFileInput.spec.tsx +++ b/packages/vuetify/src/components/VFileInput/__tests__/VFileInput.spec.tsx @@ -1,8 +1,8 @@ import { VFileInput } from '../VFileInput' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { describe, expect, it, vi } from 'vitest' import { createVuetify } from '@/framework' describe('VFileInput', () => { @@ -45,10 +45,10 @@ describe('VFileInput', () => { }) it('has affixed icons with actions', () => { - const onClickPrepend = jest.fn() - const onClickPrependInner = jest.fn() - const onClickAppendInner = jest.fn() - const onClickAppend = jest.fn() + const onClickPrepend = vi.fn() + const onClickPrependInner = vi.fn() + const onClickAppendInner = vi.fn() + const onClickAppend = vi.fn() const wrapper = mountFunction( { // https://github.com/vuetifyjs/vuetify/issues/5384 it('should not unregister children when is destroyed', async () => { - const change = jest.fn() + const change = vi.fn() const wrapper = mountFunction({ props: { modelValue: 'foo', diff --git a/packages/vuetify/src/components/VItemGroup/__tests__/__snapshots__/VItemGroup.spec.ts.snap b/packages/vuetify/src/components/VItemGroup/__tests__/__snapshots__/VItemGroup.spec.ts.snap index 5b13b579f25..b1438a1141c 100644 --- a/packages/vuetify/src/components/VItemGroup/__tests__/__snapshots__/VItemGroup.spec.ts.snap +++ b/packages/vuetify/src/components/VItemGroup/__tests__/__snapshots__/VItemGroup.spec.ts.snap @@ -1,6 +1,7 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`VItemGroup should render with a specified tag when the tag prop is provided with a value 1`] = ` - +exports[`VItemGroup > should render with a specified tag when the tag prop is provided with a value 1`] = ` +"" `; diff --git a/packages/vuetify/src/components/VList/__tests__/VList.spec.ts b/packages/vuetify/src/components/VList/__tests__/VList.spec.ts index 5e5c9986fb8..58a6a31d5d2 100644 --- a/packages/vuetify/src/components/VList/__tests__/VList.spec.ts +++ b/packages/vuetify/src/components/VList/__tests__/VList.spec.ts @@ -2,8 +2,8 @@ import { VList } from '..' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { expect, it } from 'vitest' import { createVuetify } from '@/framework' describe('VList', () => { diff --git a/packages/vuetify/src/components/VList/__tests__/VListItemMedia.spec.ts b/packages/vuetify/src/components/VList/__tests__/VListItemMedia.spec.ts index 0fcf032f775..bd799bd8200 100644 --- a/packages/vuetify/src/components/VList/__tests__/VListItemMedia.spec.ts +++ b/packages/vuetify/src/components/VList/__tests__/VListItemMedia.spec.ts @@ -2,8 +2,8 @@ import { VListItemMedia } from '..' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { expect, it } from 'vitest' import { createVuetify } from '@/framework' describe('VListItemMedia', () => { diff --git a/packages/vuetify/src/components/VList/__tests__/__snapshots__/VList.spec.ts.snap b/packages/vuetify/src/components/VList/__tests__/__snapshots__/VList.spec.ts.snap index 7c65a62b36a..185a47d2033 100644 --- a/packages/vuetify/src/components/VList/__tests__/__snapshots__/VList.spec.ts.snap +++ b/packages/vuetify/src/components/VList/__tests__/__snapshots__/VList.spec.ts.snap @@ -1,9 +1,3 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`VList should match a snapshot 1`] = ` -
-
-`; +exports[`VList > should match a snapshot 1`] = `"
"`; diff --git a/packages/vuetify/src/components/VList/__tests__/__snapshots__/VListItemMedia.spec.ts.snap b/packages/vuetify/src/components/VList/__tests__/__snapshots__/VListItemMedia.spec.ts.snap index c61febfcbf4..5ca2a776d0a 100644 --- a/packages/vuetify/src/components/VList/__tests__/__snapshots__/VListItemMedia.spec.ts.snap +++ b/packages/vuetify/src/components/VList/__tests__/__snapshots__/VListItemMedia.spec.ts.snap @@ -1,6 +1,3 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`VListItemMedia should match a snapshot 1`] = ` -
-
-`; +exports[`VListItemMedia > should match a snapshot 1`] = `"
"`; diff --git a/packages/vuetify/src/components/VMenu/__tests__/VMenu.spec.ts b/packages/vuetify/src/components/VMenu/__tests__/VMenu.spec.ts index cbf97c80cb2..6b551ec3e59 100644 --- a/packages/vuetify/src/components/VMenu/__tests__/VMenu.spec.ts +++ b/packages/vuetify/src/components/VMenu/__tests__/VMenu.spec.ts @@ -12,7 +12,7 @@ import { Wrapper, } from '@vue/test-utils' // import { keyCodes } from '../../../util/helpers' -// import { waitAnimationFrame } from '../../../../test' +// import { waitAnimationFrame } from '@/../test' describe.skip('VMenu.ts', () => { type Instance = InstanceType diff --git a/packages/vuetify/src/components/VResponsive/__tests__/VResponsive.spec.ts b/packages/vuetify/src/components/VResponsive/__tests__/VResponsive.spec.ts index 45210d6fe06..5257be49b7b 100644 --- a/packages/vuetify/src/components/VResponsive/__tests__/VResponsive.spec.ts +++ b/packages/vuetify/src/components/VResponsive/__tests__/VResponsive.spec.ts @@ -2,8 +2,8 @@ import { VResponsive } from '..' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { expect, it } from 'vitest' import { h } from 'vue' import { createVuetify } from '@/framework' diff --git a/packages/vuetify/src/components/VResponsive/__tests__/__snapshots__/VResponsive.spec.ts.snap b/packages/vuetify/src/components/VResponsive/__tests__/__snapshots__/VResponsive.spec.ts.snap index a7163b6fdde..1c08dd65da1 100644 --- a/packages/vuetify/src/components/VResponsive/__tests__/__snapshots__/VResponsive.spec.ts.snap +++ b/packages/vuetify/src/components/VResponsive/__tests__/__snapshots__/VResponsive.spec.ts.snap @@ -1,31 +1,27 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`VResponsive should force aspect ratio 1`] = ` -
-
-
-
+exports[`VResponsive > should force aspect ratio 1`] = ` +"
+
+ + +
" `; -exports[`VResponsive should render content 1`] = ` -
-
-
+exports[`VResponsive > should render content 1`] = ` +"
+
+
-
- content -
+
content
-
+
" `; -exports[`VResponsive should set height 1`] = ` -
-
-
-
+exports[`VResponsive > should set height 1`] = ` +"
+
+ + +
" `; diff --git a/packages/vuetify/src/components/VSelectionControl/__tests__/VSelectionControl.spec.tsx b/packages/vuetify/src/components/VSelectionControl/__tests__/VSelectionControl.spec.tsx index 33abc49aa23..c42bd239f69 100644 --- a/packages/vuetify/src/components/VSelectionControl/__tests__/VSelectionControl.spec.tsx +++ b/packages/vuetify/src/components/VSelectionControl/__tests__/VSelectionControl.spec.tsx @@ -2,8 +2,8 @@ import { makeVSelectionControlProps, useSelectionControl } from '../VSelectionControl' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { describe, expect, it, vi } from 'vitest' import { defineComponent, nextTick } from 'vue' import { createVuetify } from '@/framework' @@ -36,7 +36,7 @@ describe('VSelectionControl', () => { }) it('should use trueValue', async () => { - const update = jest.fn() + const update = vi.fn() const wrapper = mountFunction({ props: { trueValue: 'on', @@ -52,7 +52,7 @@ describe('VSelectionControl', () => { }) it('should use falseValue', async () => { - const update = jest.fn() + const update = vi.fn() const wrapper = mountFunction({ props: { trueValue: 'on', diff --git a/packages/vuetify/src/components/VTextField/__tests__/VTextField.spec.tsx b/packages/vuetify/src/components/VTextField/__tests__/VTextField.spec.tsx index 7402048b710..2532399c57e 100644 --- a/packages/vuetify/src/components/VTextField/__tests__/VTextField.spec.tsx +++ b/packages/vuetify/src/components/VTextField/__tests__/VTextField.spec.tsx @@ -1,8 +1,8 @@ import { VTextField } from '../VTextField' // Utilities -import { describe, expect, it } from '@jest/globals' import { mount } from '@vue/test-utils' +import { describe, expect, it, vi } from 'vitest' import { createVuetify } from '@/framework' describe('VTextField', () => { @@ -45,10 +45,10 @@ describe('VTextField', () => { }) it('has affixed icons with actions', () => { - const onClickPrepend = jest.fn() - const onClickPrependInner = jest.fn() - const onClickAppendInner = jest.fn() - const onClickAppend = jest.fn() + const onClickPrepend = vi.fn() + const onClickPrependInner = vi.fn() + const onClickAppendInner = vi.fn() + const onClickAppend = vi.fn() const wrapper = mountFunction( { @@ -45,10 +45,10 @@ describe('VTextarea', () => { }) it('has affixed icons with actions', () => { - const onClickPrepend = jest.fn() - const onClickPrependInner = jest.fn() - const onClickAppendInner = jest.fn() - const onClickAppend = jest.fn() + const onClickPrepend = vi.fn() + const onClickPrependInner = vi.fn() + const onClickAppendInner = vi.fn() + const onClickAppend = vi.fn() const wrapper = mountFunction( -
- {"foo":1} -
-
- {"bar":2} -
- +exports[`group > with complex values > should accept new value 1`] = ` +"
+
{"foo":1}
+
{"bar":2}
+
" `; -exports[`group with complex values should accept new value 2`] = ` -
-
- {"foo":1} -
-
- {"bar":2} -
-
+exports[`group > with complex values > should accept new value 2`] = ` +"
+
{"foo":1}
+
{"bar":2}
+
" `; -exports[`group with complex values should emit selected value 1`] = ` -
-
- {"foo":1} -
-
- {"bar":2} -
-
+exports[`group > with complex values > should emit selected value 1`] = ` +"
+
{"foo":1}
+
{"bar":2}
+
" `; -exports[`group with explicit values should emit new selection 1`] = ` -
-
- one -
-
- two -
-
+exports[`group > with explicit values > should emit new selection 1`] = ` +"
+
one
+
two
+
" `; -exports[`group with explicit values should not emit new selection if clicking disabled item 1`] = ` -
-
- one -
-
- two -
-
+exports[`group > with explicit values > should not emit new selection if clicking disabled item 1`] = ` +"
+
one
+
two
+
" `; -exports[`group with implicit values should emit new selection 1`] = ` -
-
-
-
-
-
+exports[`group > with implicit values > should emit new selection 1`] = ` +"
+
+
+
" `; -exports[`group with implicit values should set first non-disabled item as value when forced mandatory 1`] = ` -
-
-
-
-
-
+exports[`group > with implicit values > should set first non-disabled item as value when forced mandatory 1`] = ` +"
+
+
+
" `; diff --git a/packages/vuetify/src/composables/__tests__/__snapshots__/theme.spec.ts.snap b/packages/vuetify/src/composables/__tests__/__snapshots__/theme.spec.ts.snap index 87b59f42da9..c8531ed3b4c 100644 --- a/packages/vuetify/src/composables/__tests__/__snapshots__/theme.spec.ts.snap +++ b/packages/vuetify/src/composables/__tests__/__snapshots__/theme.spec.ts.snap @@ -1,6 +1,6 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html -exports[`createTheme should create style element 1`] = ` +exports[`createTheme > should create style element 1`] = `