Skip to content

Commit

Permalink
add e2e test for function config manifest (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecklf committed Jun 29, 2023
1 parent f523867 commit 3d8e2c8
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 6 deletions.
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server'

export async function GET() {
return NextResponse.json({ hello: 'world' })
return NextResponse.json({ hello: 'app-edge' })
}

export const runtime = 'edge'
Expand Down
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server'

export async function GET() {
return NextResponse.json({ hello: 'world' })
return NextResponse.json({ hello: 'app' })
}

export const maxDuration = 5
export const maxDuration = 1
@@ -0,0 +1,6 @@
export default function Page() {
return <p>app-edge-ssr</p>
}

export const runtime = 'edge'
export const maxDuration = 4
@@ -0,0 +1,5 @@
export default function Page() {
return <p>app-ssr</p>
}

export const maxDuration = 3
11 changes: 11 additions & 0 deletions test/e2e/app-dir/with-exported-function-config/app/layout.tsx
@@ -0,0 +1,11 @@
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
@@ -0,0 +1,10 @@
import { NextApiResponse, NextApiRequest } from 'next'

export default function handler(
_req: NextApiRequest,
res: NextApiResponse<{ hello: string }>
) {
return res.status(200).json({ hello: 'world' })
}

export const maxDuration = 1
@@ -0,0 +1,9 @@
export default function Page({ data }) {
;<p>hello {data}</p>
}

export const maxDuration = 3

export async function getServerSideProps() {
return { props: { data: 'world' } }
}
5 changes: 5 additions & 0 deletions test/e2e/app-dir/with-exported-function-config/pages/page.tsx
@@ -0,0 +1,5 @@
export default function Page() {
;<p>hello world</p>
}

export const maxDuration = 2
Expand Up @@ -14,12 +14,27 @@ createNextDescribe(

expect(functionsConfigManifest).toMatchInlineSnapshot(`
Object {
"/": Object {
"maxDuration": 5,
"/api/page-route": Object {
"maxDuration": 1,
},
"/foo/bar": Object {
"/app-route": Object {
"maxDuration": 1,
},
"/app-route-edge": Object {
"maxDuration": 2,
},
"/app-ssr": Object {
"maxDuration": 3,
},
"/app-ssr-edge": Object {
"maxDuration": 4,
},
"/page": Object {
"maxDuration": 2,
},
"/page-ssr": Object {
"maxDuration": 3,
},
}
`)
})
Expand Down

0 comments on commit 3d8e2c8

Please sign in to comment.