Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Feb 8, 2023
1 parent 91ef3f9 commit 667421f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
1 change: 0 additions & 1 deletion cli/internal/ffi/proto/messages.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/next-core/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub async fn route(
let configs = config_assets(context, project_path, next_config.page_extensions());
let router_asset = route_executor(context, project_path, configs);

// TODO this is a hack to get this files watched.
// TODO this is a hack to get these files watched.
let next_config = watch_files_hack(context, project_path);

let request = serde_json::value::to_value(&*request.await?)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// middleware.ts
import { NextResponse } from "next/server";
import type { NextRequest } from "next/server";

export function middleware(request: NextRequest) {
return NextResponse.redirect(new URL("/about-2", request.url));
}

export const config = {
matcher: "/about/:path*",
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useEffect } from "react";

export default function Home() {
useEffect(() => {
// Only run on client
import("@turbo/pack-test-harness").then(runTests);
});

return null;
}

function runTests() {
it("should allow redirects to other paths", async () => {
const res = await fetch("/about/hello");
expect(res.url.endsWith("/about-2"));
});
}

0 comments on commit 667421f

Please sign in to comment.