From 427e92da03dfdc1207a9883c014ad7ef6338313b Mon Sep 17 00:00:00 2001 From: Mister-Hope Date: Thu, 12 Dec 2024 15:17:50 +0800 Subject: [PATCH] test: fix unit test --- .../tests/node/preparePaletteFile.spec.ts | 4 +-- .../tests/node/prepareStyleFile.spec.ts | 4 +-- .../tests/generateIndex.spec.ts | 4 +-- .../tests/prepareClientAppEnhanceFile.spec.ts | 4 +-- tools/helper/tests/node/excerpt.spec.ts | 4 +-- tools/helper/tests/node/locales.spec.ts | 26 +++++++++---------- tools/helper/tests/node/text.spec.ts | 4 +-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/plugins/development/plugin-palette/tests/node/preparePaletteFile.spec.ts b/plugins/development/plugin-palette/tests/node/preparePaletteFile.spec.ts index bce1bb9ab5..3464bad2e4 100644 --- a/plugins/development/plugin-palette/tests/node/preparePaletteFile.spec.ts +++ b/plugins/development/plugin-palette/tests/node/preparePaletteFile.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { fs, path } from 'vuepress/utils' import type { PalettePluginOptions } from '../../src/node/index.js' import { preparePaletteFile, presetOptions } from '../../src/node/index.js' -const app = createBaseApp({ +const app = createBuildApp({ source: path.resolve(__dirname, 'fake-source'), theme: { name: 'test' }, bundler: {} as Bundler, diff --git a/plugins/development/plugin-palette/tests/node/prepareStyleFile.spec.ts b/plugins/development/plugin-palette/tests/node/prepareStyleFile.spec.ts index c4c9d42968..49e1b46862 100644 --- a/plugins/development/plugin-palette/tests/node/prepareStyleFile.spec.ts +++ b/plugins/development/plugin-palette/tests/node/prepareStyleFile.spec.ts @@ -1,11 +1,11 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { fs, path } from 'vuepress/utils' import type { PalettePluginOptions } from '../../src/node/index.js' import { prepareStyleFile, presetOptions } from '../../src/node/index.js' -const app = createBaseApp({ +const app = createBuildApp({ source: path.resolve(__dirname, 'fake-source'), theme: { name: 'test' }, bundler: {} as Bundler, diff --git a/plugins/search/plugin-slimsearch/tests/generateIndex.spec.ts b/plugins/search/plugin-slimsearch/tests/generateIndex.spec.ts index 2ff297b01a..61a397ac27 100644 --- a/plugins/search/plugin-slimsearch/tests/generateIndex.spec.ts +++ b/plugins/search/plugin-slimsearch/tests/generateIndex.spec.ts @@ -1,14 +1,14 @@ import { getPageExcerpt } from '@vuepress/helper' import { describe, expect, it } from 'vitest' import type { Bundler, Page } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { path } from 'vuepress/utils' import { generatePageIndex } from '../src/node/generateIndex.js' import { PathStore } from '../src/node/pathStore.js' import { emptyTheme } from './__fixtures__/theme/empty.js' -const app = createBaseApp({ +const app = createBuildApp({ bundler: {} as Bundler, source: path.resolve(__dirname, './__fixtures__/src'), theme: emptyTheme, diff --git a/plugins/tools/plugin-register-components/tests/prepareClientAppEnhanceFile.spec.ts b/plugins/tools/plugin-register-components/tests/prepareClientAppEnhanceFile.spec.ts index 64eaf8fa33..04a0fe494d 100644 --- a/plugins/tools/plugin-register-components/tests/prepareClientAppEnhanceFile.spec.ts +++ b/plugins/tools/plugin-register-components/tests/prepareClientAppEnhanceFile.spec.ts @@ -1,12 +1,12 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { fs, getDirname, path } from 'vuepress/utils' import { prepareClientConfigFile } from '../src/node/index.js' const __dirname = import.meta.dirname || getDirname(import.meta.url) -const app = createBaseApp({ +const app = createBuildApp({ source: path.resolve(__dirname, 'fake-source'), theme: { name: 'test' }, bundler: {} as Bundler, diff --git a/tools/helper/tests/node/excerpt.spec.ts b/tools/helper/tests/node/excerpt.spec.ts index 97aa775f3d..42663f4658 100644 --- a/tools/helper/tests/node/excerpt.spec.ts +++ b/tools/helper/tests/node/excerpt.spec.ts @@ -1,13 +1,13 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { path } from 'vuepress/utils' import type { PageExcerptOptions } from '../../src/node/page/excerpt.js' import { getPageExcerpt } from '../../src/node/page/excerpt.js' import { emptyTheme } from '../__fixtures__/theme/empty.js' describe('getPageExcerpt', async () => { - const app = createBaseApp({ + const app = createBuildApp({ bundler: {} as Bundler, source: path.resolve(__dirname, '../__fixtures__/src'), theme: emptyTheme, diff --git a/tools/helper/tests/node/locales.spec.ts b/tools/helper/tests/node/locales.spec.ts index 90d8092e3d..24d4b1694e 100644 --- a/tools/helper/tests/node/locales.spec.ts +++ b/tools/helper/tests/node/locales.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { path } from 'vuepress/utils' import { getLocaleConfig, @@ -55,7 +55,7 @@ it('path2lang() should convert path to lang', () => { describe('getRootLang() should get root locale lang', () => { it('should get actual root lang', () => { - const app1 = createBaseApp({ + const app1 = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, @@ -68,7 +68,7 @@ describe('getRootLang() should get root locale lang', () => { theme: emptyTheme, }) - const app2 = createBaseApp({ + const app2 = createBuildApp({ locales: { '/': { lang: 'en-US' }, '/zh/': { lang: 'zh-CN' }, @@ -86,7 +86,7 @@ describe('getRootLang() should get root locale lang', () => { }) it('Should fallback to en-US if root locale is absent', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/en/': { lang: 'en-US' }, '/zh/': { lang: 'zh-CN' }, @@ -103,7 +103,7 @@ describe('getRootLang() should get root locale lang', () => { }) it('Should fallback to en-US if root language is absent', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': {}, '/zh/': { lang: 'zh-CN' }, @@ -122,7 +122,7 @@ describe('getRootLang() should get root locale lang', () => { describe('getLocaleConfig() should generate locale', () => { it('set default value for known language', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, @@ -160,7 +160,7 @@ describe('getLocaleConfig() should generate locale', () => { }) it('Detect known language with different path', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en-us/': { lang: 'en-US' }, @@ -198,7 +198,7 @@ describe('getLocaleConfig() should generate locale', () => { }) it('use user config if exists', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, @@ -250,7 +250,7 @@ describe('getLocaleConfig() should generate locale', () => { describe('handle unknown locale', () => { it('unknown root language should fallback to first language in default config', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'unknown-Language' }, '/en/': { lang: 'en-US' }, @@ -290,7 +290,7 @@ describe('getLocaleConfig() should generate locale', () => { }) it('fallback to root language if exists', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, @@ -335,7 +335,7 @@ describe('getLocaleConfig() should generate locale', () => { }) it('fallback to en-US without root language', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/en/': { lang: 'en-US' }, '/zh/': { lang: 'zh-CN' }, @@ -386,7 +386,7 @@ describe('getLocaleConfig() should generate locale', () => { describe('handle new locale', () => { it('with default locale', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, @@ -431,7 +431,7 @@ describe('getLocaleConfig() should generate locale', () => { }) it('without default', () => { - const app = createBaseApp({ + const app = createBuildApp({ locales: { '/': { lang: 'zh-CN' }, '/en/': { lang: 'en-US' }, diff --git a/tools/helper/tests/node/text.spec.ts b/tools/helper/tests/node/text.spec.ts index 7783465637..c40b0be92e 100644 --- a/tools/helper/tests/node/text.spec.ts +++ b/tools/helper/tests/node/text.spec.ts @@ -1,13 +1,13 @@ import { describe, expect, it } from 'vitest' import type { Bundler } from 'vuepress/core' -import { createBaseApp } from 'vuepress/core' +import { createBuildApp } from 'vuepress/core' import { path } from 'vuepress/utils' import type { PageTextOptions } from '../../src/node/page/text.js' import { getPageText } from '../../src/node/page/text.js' import { emptyTheme } from '../__fixtures__/theme/empty.js' describe('getPageText', async () => { - const app = createBaseApp({ + const app = createBuildApp({ bundler: {} as Bundler, source: path.resolve(__dirname, '../__fixtures__/src'), theme: emptyTheme,