Skip to content

Commit

Permalink
Write test case for custom static() options
Browse files Browse the repository at this point in the history
  • Loading branch information
szymmis committed Jun 8, 2024
1 parent 443568d commit b3aed7c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,29 @@ describe.each(["development", "production"] as const)(
expect(response.text).toMatch(/<h1>subpath<\/h1>/);
});
});

describe.runIf(mode === "production")(
"App with custom static options",
async () => {
const app = express();

beforeAll(async () => {
process.chdir(path.join(__dirname, "envs/basic"));

ViteExpress.static({ maxAge: "1h" });

await new Promise<void>((done) => {
ViteExpress.listen(app, 0, async () => done());
});
});

test("static files have custom options", async () => {
const response = await request(app).get("/test.txt");
expect(response.headers["cache-control"]).toBe(
"public, max-age=3600",
);
});
},
);
},
);

0 comments on commit b3aed7c

Please sign in to comment.