|
1 | 1 | import { path } from '@vuepress/utils'
|
2 |
| -import { describe, expect, it, vi } from 'vitest' |
| 2 | +import { expect, it, vi } from 'vitest' |
3 | 3 | import { resolveUserConfigPath } from '../../src/index.js'
|
4 | 4 |
|
5 | 5 | const resolveFixtures = (str: string): string =>
|
6 | 6 | path.resolve(__dirname, '../__fixtures__/config', str)
|
7 | 7 |
|
8 |
| -describe('cli > config > resolveUserConfigPath', () => { |
9 |
| - it('should resolve absolute file path correctly', () => { |
10 |
| - const absolutePath = resolveFixtures('custom-config.ts') |
11 |
| - const configFile = resolveUserConfigPath(absolutePath) |
12 |
| - expect(configFile).toEqual(absolutePath) |
13 |
| - }) |
| 8 | +it('should resolve absolute file path correctly', () => { |
| 9 | + const absolutePath = resolveFixtures('custom-config.ts') |
| 10 | + const configFile = resolveUserConfigPath(absolutePath) |
| 11 | + expect(configFile).toEqual(absolutePath) |
| 12 | +}) |
14 | 13 |
|
15 |
| - it('should resolve relative file path correctly', () => { |
16 |
| - const relativePath = 'custom-config.ts' |
17 |
| - const configFile = resolveUserConfigPath(relativePath, resolveFixtures('')) |
18 |
| - expect(configFile).toEqual(resolveFixtures(relativePath)) |
19 |
| - }) |
| 14 | +it('should resolve relative file path correctly', () => { |
| 15 | + const relativePath = 'custom-config.ts' |
| 16 | + const configFile = resolveUserConfigPath(relativePath, resolveFixtures('')) |
| 17 | + expect(configFile).toEqual(resolveFixtures(relativePath)) |
| 18 | +}) |
20 | 19 |
|
21 |
| - it('should throw an error if file does not exist', () => { |
22 |
| - const consoleError = console.error |
23 |
| - console.error = vi.fn() |
| 20 | +it('should throw an error if file does not exist', () => { |
| 21 | + const consoleError = console.error |
| 22 | + console.error = vi.fn() |
24 | 23 |
|
25 |
| - expect(() => { |
26 |
| - resolveUserConfigPath('4-0-4') |
27 |
| - }).toThrow() |
28 |
| - expect(console.error).toHaveBeenCalled() |
| 24 | + expect(() => { |
| 25 | + resolveUserConfigPath('4-0-4') |
| 26 | + }).toThrow() |
| 27 | + expect(console.error).toHaveBeenCalled() |
29 | 28 |
|
30 |
| - console.error = consoleError |
31 |
| - }) |
| 29 | + console.error = consoleError |
32 | 30 | })
|
0 commit comments