diff --git a/test/byos.test.ts b/test/byos.test.ts index dead89e..b959634 100644 --- a/test/byos.test.ts +++ b/test/byos.test.ts @@ -2,7 +2,7 @@ import { test } from "vitest"; import { createServer } from "http"; -import { html, json, status } from "../src/aura"; +import { html, json, status, redirect } from "../src/aura"; import { app, route } from "../src"; const myOwnServer = createServer(); @@ -15,6 +15,7 @@ const index = route("/", () => html`

Hello World

`); server.attach(index); server.attach(route("/json", () => json({ hello: "world" }))); +server.attach(route("/redirect", () => redirect("/"))); test("byos", async (t) => { server.attach( @@ -31,6 +32,10 @@ test("byos", async (t) => { // server is a Server instance t.expect(server).toBeTruthy(); + // redirects work + const redirect = await fetch("http://localhost:4000/redirect"); + t.expect(redirect.redirected).toBe(true); + // response sends accurate status codes const response = await fetch("http://localhost:4000/"); t.expect(response.status).toBe(200); diff --git a/test/standalone.test.ts b/test/standalone.test.ts index 6cff111..54616c3 100644 --- a/test/standalone.test.ts +++ b/test/standalone.test.ts @@ -1,6 +1,6 @@ import { test } from "vitest"; -import { html, json, status } from "../src/aura"; +import { html, json, status, redirect } from "../src/aura"; import { app, route } from "../src"; const server = app(3000); @@ -9,6 +9,7 @@ const index = route("/", () => html`

Hello World

`); server.attach(index); server.attach(route("/json", () => json({ hello: "world" }))); +server.attach(route("/redirect", () => redirect("/"))); test("standalone", async (t) => { server.attach( @@ -25,6 +26,10 @@ test("standalone", async (t) => { // server is a Server instance t.expect(server).toBeTruthy(); + // redirects work + const redirect = await fetch("http://localhost:3000/redirect"); + t.expect(redirect.redirected).toBe(true); + // response sends accurate status codes const response = await fetch("http://localhost:3000/"); t.expect(response.status).toBe(200);