|
| 1 | +import path from 'node:path' |
| 2 | +import { describe, expect, test } from 'vitest' |
| 3 | +import { parseStartConfig as parseViteStartConfig } from '../src/vite/schema' |
| 4 | +import { parseStartConfig as parseRsbuildStartConfig } from '../src/rsbuild/schema' |
| 5 | + |
| 6 | +const root = process.cwd() |
| 7 | +const corePluginOpts = { framework: 'react' as const } |
| 8 | + |
| 9 | +describe('start config schema', () => { |
| 10 | + test('uses Start route defaults relative to srcDirectory', () => { |
| 11 | + const config = parseViteStartConfig({}, corePluginOpts, root) |
| 12 | + |
| 13 | + expect(config.router.routesDirectory).toBe( |
| 14 | + path.resolve(root, 'src', 'routes'), |
| 15 | + ) |
| 16 | + expect(config.router.generatedRouteTree).toBe( |
| 17 | + path.resolve(root, 'src', 'routeTree.gen.ts'), |
| 18 | + ) |
| 19 | + }) |
| 20 | + |
| 21 | + test('uses router path overrides relative to srcDirectory', () => { |
| 22 | + const config = parseRsbuildStartConfig( |
| 23 | + { |
| 24 | + srcDirectory: 'app', |
| 25 | + router: { |
| 26 | + routesDirectory: 'pages', |
| 27 | + generatedRouteTree: 'routes.gen.ts', |
| 28 | + }, |
| 29 | + }, |
| 30 | + corePluginOpts, |
| 31 | + root, |
| 32 | + ) |
| 33 | + |
| 34 | + expect(config.router.routesDirectory).toBe( |
| 35 | + path.resolve(root, 'app', 'pages'), |
| 36 | + ) |
| 37 | + expect(config.router.generatedRouteTree).toBe( |
| 38 | + path.resolve(root, 'app', 'routes.gen.ts'), |
| 39 | + ) |
| 40 | + }) |
| 41 | +}) |
0 commit comments