Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 2, 2023
1 parent bd9d70c commit 4984e0c
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/e2e/app-dir/app-simple-routes/app-simple-routes.test.ts
@@ -0,0 +1,30 @@
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'
import { Readable } from 'stream'

const bathPath = process.env.BASE_PATH ?? ''

createNextDescribe(
'app-simple-routes',
{
files: __dirname,
},
({ next, isNextDeploy, isNextDev, isNextStart }) => {
describe('works with simple routes', () => {
it('renders a node route', async () => {
expect(
JSON.parse(await next.render(bathPath + '/api/node.json'))
).toEqual({
pathname: '/api/node.json',
})
})
it('renders a edge route', async () => {
expect(
JSON.parse(await next.render(bathPath + '/api/edge.json'))
).toEqual({
pathname: '/api/edge.json',
})
})
})
}
)
9 changes: 9 additions & 0 deletions test/e2e/app-dir/app-simple-routes/app/api/edge.json/route.ts
@@ -0,0 +1,9 @@
import { NextRequest, NextResponse } from 'next/server'

export const GET = (req: NextRequest) => {
return NextResponse.json({
pathname: req.nextUrl.pathname,
})
}

export const runtime = 'edge'
7 changes: 7 additions & 0 deletions test/e2e/app-dir/app-simple-routes/app/api/node.json/route.ts
@@ -0,0 +1,7 @@
import { NextRequest, NextResponse } from 'next/server'

export const GET = (req: NextRequest) => {
return NextResponse.json({
pathname: req.nextUrl.pathname,
})
}
10 changes: 10 additions & 0 deletions test/e2e/app-dir/app-simple-routes/next.config.js
@@ -0,0 +1,10 @@
/**
* @type {import('next').NextConfig}
*/
const config = {
typescript: {
ignoreBuildErrors: true,
},
}

module.exports = config
2 changes: 2 additions & 0 deletions test/turbopack-tests-manifest.js
Expand Up @@ -3,6 +3,8 @@
// be enabled here
const enabledTests = [
'test/development/api-cors-with-rewrite/index.test.ts',
'test/e2e/app-dir/app-rendering/rendering.test.ts',
'test/e2e/app-dir/app-simple-routes/app-simple-routes.test.ts',
'test/integration/bigint/test/index.test.js',
]

Expand Down

0 comments on commit 4984e0c

Please sign in to comment.