Files
tuono/packages/fs-router-vite-plugin/src/build-route-config.spec.ts
T

72 lines
2.2 KiB
TypeScript
Raw Normal View History

2024-07-23 19:13:18 +02:00
import { describe, it, expect } from 'vitest'
import { buildRouteConfig } from './build-route-config'
const routes = [
{
filePath: 'posts/my-post.tsx',
fullPath:
'/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/my-post.tsx',
routePath: '/posts/my-post',
variableName: 'PostsMyPost',
parent: {
filePath: 'posts/__root.tsx',
fullPath:
'/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/__root.tsx',
routePath: '/posts/__root',
variableName: 'Postsroot',
path: '/posts/__root',
cleanedPath: '/posts',
children: undefined,
},
path: '/posts/my-post',
cleanedPath: '/posts/my-post',
},
{
filePath: 'posts/index.tsx',
fullPath:
'/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/index.tsx',
routePath: '/posts/',
variableName: 'PostsIndex',
parent: {
filePath: 'posts/__root.tsx',
fullPath:
'/home/valerio/Documents/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/__root.tsx',
routePath: '/posts/__root',
variableName: 'Postsroot',
path: '/posts/__root',
cleanedPath: '/posts',
children: undefined,
},
path: '/posts/',
cleanedPath: '/posts/',
},
{
filePath: 'posts/[post].tsx',
fullPath:
'/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/index.tsx',
routePath: '/posts/',
variableName: 'PostspostIndex',
parent: {
filePath: 'posts/__root.tsx',
fullPath:
'/tuono/packages/fs-router-vite-plugin/tests/generator/multi-level-root-dynamic/routes/posts/__root.tsx',
routePath: '/posts/__root',
variableName: 'Postsroot',
path: '/posts/__root',
cleanedPath: '/posts',
children: undefined,
},
path: '/posts/',
cleanedPath: '/posts/',
},
]
describe('buildRouteConfig works', async () => {
it('Should build the correct config', () => {
const expectedConfig =
'PostsMyPostRoute,PostsIndexRoute,PostspostIndexRoute'
const config = buildRouteConfig(routes)
expect(config).toStrictEqual(expectedConfig)
})
})