From e978a28b0c5f847e7791d8878615e1cbd1ef2572 Mon Sep 17 00:00:00 2001 From: Mathanraj Date: Sun, 21 Jan 2024 02:06:46 +0530 Subject: [PATCH] solve issue #8 : Added test for contact routes --- server/tests/integration/contact.test.js | 25 ++++++++++++++++++++++++ server/tests/integration/product.test.js | 0 2 files changed, 25 insertions(+) create mode 100644 server/tests/integration/contact.test.js create mode 100644 server/tests/integration/product.test.js diff --git a/server/tests/integration/contact.test.js b/server/tests/integration/contact.test.js new file mode 100644 index 0000000..b8347d6 --- /dev/null +++ b/server/tests/integration/contact.test.js @@ -0,0 +1,25 @@ +const request = require("supertest"); +let server; +describe("contact-us", () => { + beforeEach(() => { + server = require("../../app"); + }); + afterEach(async () => { + await server.close(); + }); + describe("/", () => { + it("should return a statuscode of 200 if body have object", async () => { + const result = await request(server).post("/contact-us/").send({ + name: "b", + email: "b", + subject: "b", + }); + expect(result.statusCode).toBe(200); + }); + + it("should return a statuscode of 400 if no body is send", async () => { + const result = await request(server).post("/contact-us/").send({}); + expect(result.statusCode).toBe(400); + }); + }); +}); diff --git a/server/tests/integration/product.test.js b/server/tests/integration/product.test.js new file mode 100644 index 0000000..e69de29