Skip to content

Commit

Permalink
test: fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Dec 12, 2024
1 parent 5a081ff commit 427e92d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions plugins/search/plugin-slimsearch/tests/generateIndex.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tools/helper/tests/node/excerpt.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
26 changes: 13 additions & 13 deletions tools/helper/tests/node/locales.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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' },
Expand All @@ -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' },
Expand All @@ -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' },
Expand All @@ -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' },
Expand All @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down Expand Up @@ -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' },
Expand Down
4 changes: 2 additions & 2 deletions tools/helper/tests/node/text.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 427e92d

Please sign in to comment.