From 0b6f25b988565d4146a13e029c2bfaaa4b8ac70a Mon Sep 17 00:00:00 2001 From: Kia Ishii Date: Tue, 14 Jun 2022 16:46:09 +0900 Subject: [PATCH] test: add test for client utils close #617 --- .../theme-default/support/utils.spec.ts | 13 + __tests__/shims.ts | 1 + __tests__/vitest.config.ts | 4 +- package.json | 2 +- pnpm-lock.yaml | 302 +++++++++++++++++- 5 files changed, 308 insertions(+), 14 deletions(-) create mode 100644 __tests__/client/theme-default/support/utils.spec.ts create mode 100644 __tests__/shims.ts diff --git a/__tests__/client/theme-default/support/utils.spec.ts b/__tests__/client/theme-default/support/utils.spec.ts new file mode 100644 index 00000000..ac6a668d --- /dev/null +++ b/__tests__/client/theme-default/support/utils.spec.ts @@ -0,0 +1,13 @@ +import { describe, test, expect } from 'vitest' +import * as Utils from 'client/theme-default/support/utils' + +describe('client/theme-default/utils', () => { + describe('ensureStartingSlash', () => { + test('it adds slash to the beginning of the given path', () => { + expect(Utils.ensureStartingSlash('path')).toBe('/path') + expect(Utils.ensureStartingSlash('path/nested')).toBe('/path/nested') + expect(Utils.ensureStartingSlash('/path')).toBe('/path') + expect(Utils.ensureStartingSlash('/path/nested')).toBe('/path/nested') + }) + }) +}) diff --git a/__tests__/shims.ts b/__tests__/shims.ts new file mode 100644 index 00000000..64aacc6f --- /dev/null +++ b/__tests__/shims.ts @@ -0,0 +1 @@ +export default '{}' diff --git a/__tests__/vitest.config.ts b/__tests__/vitest.config.ts index 96d9ca01..8dc0fade 100644 --- a/__tests__/vitest.config.ts +++ b/__tests__/vitest.config.ts @@ -7,8 +7,10 @@ const dir = dirname(fileURLToPath(import.meta.url)) export default defineConfig({ resolve: { alias: { + '@siteData': resolve(dir, './shims.ts'), + client: resolve(dir, '../src/client'), node: resolve(dir, '../src/node'), - client: resolve(dir, '../src/client') + vitepress: resolve(dir, '../src/client') } }, test: { diff --git a/package.json b/package.json index 27cedf18..cd4787ba 100644 --- a/package.json +++ b/package.json @@ -139,7 +139,7 @@ "sirv": "^1.0.12", "supports-color": "^9.2.2", "typescript": "^4.7.2", - "vitest": "^0.10.4" + "vitest": "^0.14.2" }, "pnpm": { "peerDependencyRules": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a0cb63f7..0a2e3702 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,7 +69,7 @@ importers: supports-color: ^9.2.2 typescript: ^4.7.2 vite: ^2.9.7 - vitest: ^0.10.4 + vitest: ^0.14.2 vue: ^3.2.33 dependencies: '@docsearch/css': 3.1.0 @@ -139,7 +139,7 @@ importers: sirv: 1.0.17 supports-color: 9.2.2 typescript: 4.7.2 - vitest: 0.10.5 + vitest: 0.14.2_supports-color@9.2.2 docs: specifiers: {} @@ -1403,6 +1403,19 @@ packages: supports-color: 9.2.2 dev: true + /debug/4.3.4_supports-color@9.2.2: + resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + dependencies: + ms: 2.1.2 + supports-color: 9.2.2 + dev: true + /decamelize-keys/1.1.0: resolution: {integrity: sha1-0XGoeTMlKAfrPLYdwcFEXQeN8tk=} engines: {node: '>=0.10.0'} @@ -1516,6 +1529,16 @@ packages: cpu: [x64] os: [android] requiresBuild: true + dev: false + optional: true + + /esbuild-android-64/0.14.43: + resolution: {integrity: sha512-kqFXAS72K6cNrB6RiM7YJ5lNvmWRDSlpi7ZuRZ1hu1S3w0zlwcoCxWAyM23LQUyZSs1PbjHgdbbfYAN8IGh6xg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: true optional: true /esbuild-android-arm64/0.14.3: @@ -1532,6 +1555,16 @@ packages: cpu: [arm64] os: [android] requiresBuild: true + dev: false + optional: true + + /esbuild-android-arm64/0.14.43: + resolution: {integrity: sha512-bKS2BBFh+7XZY9rpjiHGRNA7LvWYbZWP87pLehggTG7tTaCDvj8qQGOU/OZSjCSKDYbgY7Q+oDw8RlYQ2Jt2BA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true optional: true /esbuild-darwin-64/0.14.3: @@ -1548,6 +1581,16 @@ packages: cpu: [x64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /esbuild-darwin-64/0.14.43: + resolution: {integrity: sha512-/3PSilx011ttoieRGkSZ0XV8zjBf2C9enV4ScMMbCT4dpx0mFhMOpFnCHkOK0pWGB8LklykFyHrWk2z6DENVUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true optional: true /esbuild-darwin-arm64/0.14.3: @@ -1564,6 +1607,16 @@ packages: cpu: [arm64] os: [darwin] requiresBuild: true + dev: false + optional: true + + /esbuild-darwin-arm64/0.14.43: + resolution: {integrity: sha512-1HyFUKs8DMCBOvw1Qxpr5Vv/ThNcVIFb5xgXWK3pyT40WPvgYIiRTwJCvNs4l8i5qWF8/CK5bQxJVDjQvtv0Yw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true optional: true /esbuild-freebsd-64/0.14.3: @@ -1580,6 +1633,16 @@ packages: cpu: [x64] os: [freebsd] requiresBuild: true + dev: false + optional: true + + /esbuild-freebsd-64/0.14.43: + resolution: {integrity: sha512-FNWc05TPHYgaXjbPZO5/rJKSBslfG6BeMSs8GhwnqAKP56eEhvmzwnIz1QcC9cRVyO+IKqWNfmHFkCa1WJTULA==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true optional: true /esbuild-freebsd-arm64/0.14.3: @@ -1596,6 +1659,16 @@ packages: cpu: [arm64] os: [freebsd] requiresBuild: true + dev: false + optional: true + + /esbuild-freebsd-arm64/0.14.43: + resolution: {integrity: sha512-amrYopclz3VohqisOPR6hA3GOWA3LZC1WDLnp21RhNmoERmJ/vLnOpnrG2P/Zao+/erKTCUqmrCIPVtj58DRoA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true optional: true /esbuild-linux-32/0.14.3: @@ -1612,6 +1685,16 @@ packages: cpu: [ia32] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-32/0.14.43: + resolution: {integrity: sha512-KoxoEra+9O3AKVvgDFvDkiuddCds6q71owSQEYwjtqRV7RwbPzKxJa6+uyzUulHcyGVq0g15K0oKG5CFBcvYDw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-64/0.14.3: @@ -1628,6 +1711,16 @@ packages: cpu: [x64] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-64/0.14.43: + resolution: {integrity: sha512-EwINwGMyiJMgBby5/SbMqKcUhS5AYAZ2CpEBzSowsJPNBJEdhkCTtEjk757TN/wxgbu3QklqDM6KghY660QCUw==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-arm/0.14.3: @@ -1644,6 +1737,16 @@ packages: cpu: [arm] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-arm/0.14.43: + resolution: {integrity: sha512-e6YzQUoDxxtyamuF12eVzzRC7bbEFSZohJ6igQB9tBqnNmIQY3fI6Cns3z2wxtbZ3f2o6idkD2fQnlvs2902Dg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-arm64/0.14.3: @@ -1660,6 +1763,16 @@ packages: cpu: [arm64] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-arm64/0.14.43: + resolution: {integrity: sha512-UlSpjMWllAc70zYbHxWuDS3FJytyuR/gHJYBr8BICcTNb/TSOYVBg6U7b3jZ3mILTrgzwJUHwhEwK18FZDouUQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-mips64le/0.14.3: @@ -1676,6 +1789,16 @@ packages: cpu: [mips64el] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-mips64le/0.14.43: + resolution: {integrity: sha512-f+v8cInPEL1/SDP//CfSYzcDNgE4CY3xgDV81DWm3KAPWzhvxARrKxB1Pstf5mB56yAslJDxu7ryBUPX207EZA==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-ppc64le/0.14.3: @@ -1692,6 +1815,16 @@ packages: cpu: [ppc64] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-ppc64le/0.14.43: + resolution: {integrity: sha512-5wZYMDGAL/K2pqkdIsW+I4IR41kyfHr/QshJcNpUfK3RjB3VQcPWOaZmc+74rm4ZjVirYrtz+jWw0SgxtxRanA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-riscv64/0.14.39: @@ -1700,6 +1833,16 @@ packages: cpu: [riscv64] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-riscv64/0.14.43: + resolution: {integrity: sha512-lYcAOUxp85hC7lSjycJUVSmj4/9oEfSyXjb/ua9bNl8afonaduuqtw7hvKMoKuYnVwOCDw4RSfKpcnIRDWq+Bw==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-linux-s390x/0.14.39: @@ -1708,6 +1851,16 @@ packages: cpu: [s390x] os: [linux] requiresBuild: true + dev: false + optional: true + + /esbuild-linux-s390x/0.14.43: + resolution: {integrity: sha512-27e43ZhHvhFE4nM7HqtUbMRu37I/4eNSUbb8FGZWszV+uLzMIsHDwLoBiJmw7G9N+hrehNPeQ4F5Ujad0DrUKQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true optional: true /esbuild-netbsd-64/0.14.3: @@ -1724,6 +1877,16 @@ packages: cpu: [x64] os: [netbsd] requiresBuild: true + dev: false + optional: true + + /esbuild-netbsd-64/0.14.43: + resolution: {integrity: sha512-2mH4QF6hHBn5zzAfxEI/2eBC0mspVsZ6UVo821LpAJKMvLJPBk3XJO5xwg7paDqSqpl7p6IRrAenW999AEfJhQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true optional: true /esbuild-openbsd-64/0.14.3: @@ -1740,6 +1903,16 @@ packages: cpu: [x64] os: [openbsd] requiresBuild: true + dev: false + optional: true + + /esbuild-openbsd-64/0.14.43: + resolution: {integrity: sha512-ZhQpiZjvqCqO8jKdGp9+8k9E/EHSA+zIWOg+grwZasI9RoblqJ1QiZqqi7jfd6ZrrG1UFBNGe4m0NFxCFbMVbg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true optional: true /esbuild-sunos-64/0.14.3: @@ -1756,6 +1929,16 @@ packages: cpu: [x64] os: [sunos] requiresBuild: true + dev: false + optional: true + + /esbuild-sunos-64/0.14.43: + resolution: {integrity: sha512-DgxSi9DaHReL9gYuul2rrQCAapgnCJkh3LSHPKsY26zytYppG0HgkgVF80zjIlvEsUbGBP/GHQzBtrezj/Zq1Q==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true optional: true /esbuild-windows-32/0.14.3: @@ -1772,6 +1955,16 @@ packages: cpu: [ia32] os: [win32] requiresBuild: true + dev: false + optional: true + + /esbuild-windows-32/0.14.43: + resolution: {integrity: sha512-Ih3+2O5oExiqm0mY6YYE5dR0o8+AspccQ3vIAtRodwFvhuyGLjb0Hbmzun/F3Lw19nuhPMu3sW2fqIJ5xBxByw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true optional: true /esbuild-windows-64/0.14.3: @@ -1788,6 +1981,16 @@ packages: cpu: [x64] os: [win32] requiresBuild: true + dev: false + optional: true + + /esbuild-windows-64/0.14.43: + resolution: {integrity: sha512-8NsuNfI8xwFuJbrCuI+aBqNTYkrWErejFO5aYM+yHqyHuL8mmepLS9EPzAzk8rvfaJrhN0+RvKWAcymViHOKEw==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true optional: true /esbuild-windows-arm64/0.14.3: @@ -1804,6 +2007,16 @@ packages: cpu: [arm64] os: [win32] requiresBuild: true + dev: false + optional: true + + /esbuild-windows-arm64/0.14.43: + resolution: {integrity: sha512-7ZlD7bo++kVRblJEoG+cepljkfP8bfuTPz5fIXzptwnPaFwGS6ahvfoYzY7WCf5v/1nX2X02HDraVItTgbHnKw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true optional: true /esbuild/0.14.3: @@ -1856,6 +2069,35 @@ packages: esbuild-windows-32: 0.14.39 esbuild-windows-64: 0.14.39 esbuild-windows-arm64: 0.14.39 + dev: false + + /esbuild/0.14.43: + resolution: {integrity: sha512-Uf94+kQmy/5jsFwKWiQB4hfo/RkM9Dh7b79p8yqd1tshULdr25G2szLz631NoH3s2ujnKEKVD16RmOxvCNKRFA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-64: 0.14.43 + esbuild-android-arm64: 0.14.43 + esbuild-darwin-64: 0.14.43 + esbuild-darwin-arm64: 0.14.43 + esbuild-freebsd-64: 0.14.43 + esbuild-freebsd-arm64: 0.14.43 + esbuild-linux-32: 0.14.43 + esbuild-linux-64: 0.14.43 + esbuild-linux-arm: 0.14.43 + esbuild-linux-arm64: 0.14.43 + esbuild-linux-mips64le: 0.14.43 + esbuild-linux-ppc64le: 0.14.43 + esbuild-linux-riscv64: 0.14.43 + esbuild-linux-s390x: 0.14.43 + esbuild-netbsd-64: 0.14.43 + esbuild-openbsd-64: 0.14.43 + esbuild-sunos-64: 0.14.43 + esbuild-windows-32: 0.14.43 + esbuild-windows-64: 0.14.43 + esbuild-windows-arm64: 0.14.43 + dev: true /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} @@ -1989,7 +2231,7 @@ packages: dev: true /get-func-name/2.0.0: - resolution: {integrity: sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=} + resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} dev: true /get-intrinsic/1.1.1: @@ -2105,7 +2347,7 @@ packages: source-map: 0.6.1 wordwrap: 1.0.0 optionalDependencies: - uglify-js: 3.14.2 + uglify-js: 3.16.0 dev: true /hard-rejection/2.1.0: @@ -3235,6 +3477,15 @@ packages: hasBin: true optionalDependencies: fsevents: 2.3.2 + dev: false + + /rollup/2.75.6: + resolution: {integrity: sha512-OEf0TgpC9vU6WGROJIk1JA3LR5vk/yvqlzxqdrE2CzzXnqKXNzbAwlWUXis8RS3ZPe7LAq+YUxsRa0l3r27MLA==} + engines: {node: '>=10.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: true /run-parallel/1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -3585,8 +3836,8 @@ packages: engines: {node: '>=14.0.0'} dev: true - /tinyspy/0.3.2: - resolution: {integrity: sha512-2+40EP4D3sFYy42UkgkFFB+kiX2Tg3URG/lVvAZFfLxgGpnWl5qQJuBw1gaLttq8UOS+2p3C0WrhJnQigLTT2Q==} + /tinyspy/0.3.3: + resolution: {integrity: sha512-gRiUR8fuhUf0W9lzojPf1N1euJYA30ISebSfgca8z76FOvXtVXqd5ojEIaKLWbDQhAaC3ibxZIjqbyi4ybjcTw==} engines: {node: '>=14.0.0'} dev: true @@ -3658,8 +3909,8 @@ packages: resolution: {integrity: sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==} dev: true - /uglify-js/3.14.2: - resolution: {integrity: sha512-rtPMlmcO4agTUfz10CbgJ1k6UAoXM2gWb3GoMPPZB/+/Ackf8lNWk11K4rYi2D0apgoFRLtQOZhb+/iGNJq26A==} + /uglify-js/3.16.0: + resolution: {integrity: sha512-FEikl6bR30n0T3amyBh3LoiBdqHRy/f4H80+My34HOesOKyHfOsxAPAxOoqC0JUnC1amnO0IwkYC3sko51caSw==} engines: {node: '>=0.8.0'} hasBin: true requiresBuild: true @@ -3702,6 +3953,30 @@ packages: engines: {node: '>= 0.8'} dev: true + /vite/2.9.12: + resolution: {integrity: sha512-suxC36dQo9Rq1qMB2qiRorNJtJAdxguu5TMvBHOc/F370KvqAe9t48vYp+/TbPKRNrMh/J55tOUmkuIqstZaew==} + engines: {node: '>=12.2.0'} + hasBin: true + peerDependencies: + less: '*' + sass: '*' + stylus: '*' + peerDependenciesMeta: + less: + optional: true + sass: + optional: true + stylus: + optional: true + dependencies: + esbuild: 0.14.43 + postcss: 8.4.14 + resolve: 1.22.0 + rollup: 2.75.6 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /vite/2.9.9: resolution: {integrity: sha512-ffaam+NgHfbEmfw/Vuh6BHKKlI/XIAhxE5QSS7gFLIngxg171mg1P3a4LSRME0z2ZU1ScxoKzphkipcYwSD5Ew==} engines: {node: '>=12.2.0'} @@ -3724,9 +3999,10 @@ packages: rollup: 2.60.1 optionalDependencies: fsevents: 2.3.2 + dev: false - /vitest/0.10.5: - resolution: {integrity: sha512-4qXdNbHwAd9YcsztJoVMWUQGcMATVlY9Xd95I3KQ2JJwDLTL97f/jgfGRotqptvNxdlmme5TBY0Gv+l6+JSYvA==} + /vitest/0.14.2_supports-color@9.2.2: + resolution: {integrity: sha512-vXQUl8OUCqHmxKWscMGL+6Xl1pBJmYHZ8N85iNpLGrirAC2vhspu7b73ShRcLonmZT44BYZW+LBAVvn0L4jyVA==} engines: {node: '>=v14.16.0'} hasBin: true peerDependencies: @@ -3747,14 +4023,16 @@ packages: '@types/chai': 4.3.1 '@types/chai-subset': 1.3.3 chai: 4.3.6 + debug: 4.3.4_supports-color@9.2.2 local-pkg: 0.4.1 tinypool: 0.1.3 - tinyspy: 0.3.2 - vite: 2.9.9 + tinyspy: 0.3.3 + vite: 2.9.12 transitivePeerDependencies: - less - sass - stylus + - supports-color dev: true /vscode-oniguruma/1.6.2: