Skip to content

Commit

Permalink
test: update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhanbo committed Oct 14, 2024
1 parent b8f4326 commit e01ba19
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
3 changes: 0 additions & 3 deletions __mocks__/fs.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions __mocks__/fs/promises.cjs

This file was deleted.

4 changes: 1 addition & 3 deletions cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import { createPackageJson } from './packageJson.js'
import { createRender } from './render.js'
import { getTemplate, readFiles, readJsonFile, writeFiles } from './utils/index.js'

export async function generate(mode: Mode, data: ResolvedData): Promise<void> {
const cwd = process.cwd()

export async function generate(mode: Mode, data: ResolvedData, cwd = process.cwd()): Promise<void> {
let userPkg: Record<string, any> = {}
if (mode === Mode.init) {
const pkgPath = path.join(cwd, 'package.json')
Expand Down
7 changes: 4 additions & 3 deletions plugins/plugin-md-power/__test__/langReplPlugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { path } from '@vuepress/utils'
import { resolveModule } from 'local-pkg'
import MarkdownIt from 'markdown-it'
import { fs, vol } from 'memfs'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { langReplPlugin } from '../src/node/container/langRepl.js'

vi.mock('node:fs')
vi.mock('node:fs/promises')
vi.mock('node:fs', () => fs)
vi.mock('node:fs/promises', () => fs.promises)

beforeEach(() => vol.reset())
afterEach(() => vol.reset())

const FENCE = '```'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function createEmbedRuleBlock<Meta extends Record<string, any> = Record<s
return false

// return true as we have matched the syntax
/* istanbul ignore if -- @preserve */
if (silent)
return true

Expand Down
6 changes: 6 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { defineConfig } from 'vitest/config'

export default defineConfig({
test: {
include: ['**/__test__/**/*.spec.[tj]s'],
exclude: [
'**/node_modules/**',
'**/dist/**',
'**/lib/**',
],
coverage: {
enabled: true,
provider: 'istanbul',
Expand Down

0 comments on commit e01ba19

Please sign in to comment.