Skip to content

Commit

Permalink
feat: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
c0dedance committed Oct 18, 2023
1 parent 0418b0a commit 5a83885
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion e2e/playground/basic/docs/index.md

This file was deleted.

15 changes: 15 additions & 0 deletions src/node/__test__/plugin-routes/RouteService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,19 @@ describe('RouteService', async () => {
]
`)
})
test('generate routes code', async () => {
const code = routeService.generateRoutes().replaceAll(testDir, 'TEST_DIR')
expect(code).toMatchInlineSnapshot(`
"import React from 'react'
import Route0 from 'TEST_DIR/b.tsx';
import Route1 from 'TEST_DIR/guide/a.tsx';
import Route2 from 'TEST_DIR/guide/index.tsx';
export const routes = [
{ \\"path\\": '/b', \\"element\\": React.createElement(Route0)},
{ \\"path\\": '/guide/a', \\"element\\": React.createElement(Route1)},
{ \\"path\\": '/guide', \\"element\\": React.createElement(Route2)},
]
"
`)
})
})
1 change: 0 additions & 1 deletion src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export async function resolveConfig(
configDeps: userConfigDeps,
siteData: resolveSiteData(userConfig as UserConfig),
}
console.log(siteConfig, 'siteConfig')
return siteConfig
}

Expand Down
5 changes: 2 additions & 3 deletions src/node/plugin-routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export function pluginRoutes(options: PluginOptions): Plugin {
},
load(id: string) {
if (id === '\0' + CONVENTIONAL_ROUTE_ID) {
const a = routeService.generateRoutes()
console.log('generateRoutes', a)
return a
const code = routeService.generateRoutes()
return code
}
},
}
Expand Down
1 change: 0 additions & 1 deletion src/runtime/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useRoutes } from 'react-router-dom'
import { routes } from 'rpress:routes'
console.log('routes', routes)

export const Content = () => {
const routeElement = useRoutes(routes)
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/client-entry.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import App from './App'
import siteData from 'rpress:site-data'

console.log(siteData)

function renderInBrowser() {
const containerEl = document.getElementById('root')
Expand Down

0 comments on commit 5a83885

Please sign in to comment.