From 2132babc51d8271a6de8dee02c4e5a61af7cd8cd Mon Sep 17 00:00:00 2001 From: Gitea Date: Thu, 16 Apr 2026 15:58:11 +0530 Subject: [PATCH] sixth commit --- index.js | 8 ++++++-- test.js | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 5a296bd..ed535bf 100644 --- a/index.js +++ b/index.js @@ -4,19 +4,23 @@ const app = express(); app.use(express.json()); app.get("/", (req, res) => { - res.send("🚀 Home Route Working"); + res.json({ + status: "OK", + message: "Home Route Working" + }); }); app.get("/health", (req, res) => { res.json({ status: "OK", - message: "Server is healthy ✅" + message: "Server is healthy" }); }); module.exports = app; // only start server if not testing +// It ensures the server starts only when the file is run directly, not when it is imported for testing. if (require.main === module) { app.listen(3000, () => { console.log("Server running on port 3000"); diff --git a/test.js b/test.js index d8e58ab..f57ec65 100644 --- a/test.js +++ b/test.js @@ -13,9 +13,9 @@ const app = require("./index"); describe("API Testing", () => { - test("GET / should return home message", async () => { + test("GET / should return status ok", async () => { const res = await request(app).get("/"); - expect(res.text).toBe("🚀 Home Route Working"); + expect(res.body.status).toBe("ok"); }); test("GET /health should return status OK", async () => {