Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions tests/fixtures/dist-dir/app/api/headers/route.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { cookies } from 'next/headers'

export const GET = async () => {
cookies().set('foo', 'foo1')
cookies().set('bar', 'bar1')
const localCookies = await cookies()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localCookies.set('foo', 'foo1')
localCookies.set('bar', 'bar1')

// Key, value, options
cookies().set('test1', 'value1', { secure: true })
localCookies.set('test1', 'value1', { secure: true })

// One object
cookies().set({
localCookies.set({
name: 'test2',
value: 'value2',
httpOnly: true,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/middleware-src/src/app/test/next/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { headers } from 'next/headers'

export default function Page() {
const headersList = headers()
export default async function Page() {
const headersList = await headers()
const message = headersList.get('x-hello-from-middleware-req')

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { headers } from 'next/headers'

export default function Page() {
const headersList = headers()
export default async function Page() {
const headersList = await headers()
const message = headersList.get('x-hello-from-middleware-req')

return (
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/middleware/app/test/next/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { headers } from 'next/headers'

export default function Page() {
const headersList = headers()
export default async function Page() {
const headersList = await headers()
const message = headersList.get('x-hello-from-middleware-req')

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { cookies } from 'next/headers'

export const GET = async () => {
cookies().set('foo', 'foo1')
cookies().set('bar', 'bar1')
const localCookies = await cookies()
localCookies.set('foo', 'foo1')
localCookies.set('bar', 'bar1')

// Key, value, options
cookies().set('test1', 'value1', { secure: true })
localCookies.set('test1', 'value1', { secure: true })

// One object
cookies().set({
localCookies.set({
name: 'test2',
value: 'value2',
httpOnly: true,
Expand All @@ -23,4 +24,4 @@ export const GET = async () => {
['Set-Cookie', 'baz=baz2'],
],
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ async function getData(params) {
}

export default async function Page({ params }) {
const data = await getData(params)
const { id } = await params
const data = await getData({ id })

return (
<>
Expand All @@ -19,7 +20,7 @@ export default async function Page({ params }) {
<dt>Show</dt>
<dd data-testid="name">{data.name}</dd>
<dt>Param</dt>
<dd data-testid="id">{params.id}</dd>
<dd data-testid="id">{id}</dd>
<dt>Time</dt>
<dd data-testid="date-now">{Date.now()}</dd>
<dt>Time from fetch response</dt>
Expand Down
5 changes: 3 additions & 2 deletions tests/fixtures/revalidate-fetch/app/posts/[id]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ async function getData(params) {
}

export default async function Page({ params }) {
const data = await getData(params)
const { id } = await params
const data = await getData({ id })

return (
<>
Expand All @@ -24,7 +25,7 @@ export default async function Page({ params }) {
<dt>Show</dt>
<dd data-testid="name">{data.name}</dd>
<dt>Param</dt>
<dd data-testid="id">{params.id}</dd>
<dd data-testid="id">{id}</dd>
<dt>Time</dt>
<dd data-testid="date-now">{Date.now()}</dd>
<dt>Time from fetch response</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ async function getData(params) {
}

export default async function Page({ params }) {
const data = await getData(params)
const { id } = await params
const data = await getData({ id })

return (
<>
Expand All @@ -32,7 +33,7 @@ export default async function Page({ params }) {
<dt>Show</dt>
<dd data-testid="name">{data.name}</dd>
<dt>Param</dt>
<dd data-testid="id">{params.id}</dd>
<dd data-testid="id">{id}</dd>
<dt>Time</dt>
<dd data-testid="date-now">{Date.now()}</dd>
<dt>Time from fetch response</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export function generateStaticParams() {
return [{ slug: 'first' }, { slug: 'second' }]
}

export const GET = (_req: NextRequest, { params }) => {
return NextResponse.json({ params })
export const GET = async (_req: NextRequest, { params }) => {
return NextResponse.json({ params: await params })
}
23 changes: 14 additions & 9 deletions tests/fixtures/server-components/app/product/[slug]/page.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const Product = ({ params }) => (
<div>
<h1>Product {decodeURIComponent(params.slug)}</h1>
<p>
This page uses generateStaticParams() to prerender a Product
<span data-testid="date-now">{new Date().toISOString()}</span>
</p>
</div>
)
const Product = async ({ params }) => {
const { slug } = await params
return (
<div>
<h1>Product {decodeURIComponent(slug)}</h1>
<p>
This page uses generateStaticParams() to prerender a Product
<span data-testid="date-now">{new Date().toISOString()}</span>
</p>
</div>
)
}

export async function generateStaticParams() {
return [
Expand All @@ -17,4 +20,6 @@ export async function generateStaticParams() {
]
}

export const dynamic = 'force-static'

export default Product
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ async function getData(params) {
}

export default async function Page({ params }) {
const data = await getData(params)
const { id } = await params
const data = await getData({ id })

return (
<>
Expand All @@ -22,7 +23,7 @@ export default async function Page({ params }) {
<dt>Show</dt>
<dd>{data.name}</dd>
<dt>Param</dt>
<dd>{params.id}</dd>
<dd>{id}</dd>
<dt>Time</dt>
<dd data-testid="date-now">{new Date().toISOString()}</dd>
</dl>
Expand Down
9 changes: 5 additions & 4 deletions tests/fixtures/simple/app/api/headers/route.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { cookies } from 'next/headers'

export const GET = async () => {
cookies().set('foo', 'foo1')
cookies().set('bar', 'bar1')
const localCookies = await cookies()
localCookies.set('foo', 'foo1')
localCookies.set('bar', 'bar1')

// Key, value, options
cookies().set('test1', 'value1', { secure: true })
localCookies.set('test1', 'value1', { secure: true })

// One object
cookies().set({
localCookies.set({
name: 'test2',
value: 'value2',
httpOnly: true,
Expand Down
Loading