Skip to content

Commit 8a8c85f

Browse files
committed
added normal scenerio test for pet
1 parent e240bb0 commit 8a8c85f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

__test__/pet.test.js

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const app = require("../app");
2+
const request = require("supertest");
3+
4+
describe("Pet Service", () => {
5+
describe("Normal scenario", () => {
6+
it("should save the pet in the database", async () => {
7+
const response = await request(app).post("/api/pet").send({
8+
id: 5,
9+
name: "Sandy",
10+
type: "Hamster"
11+
});
12+
13+
expect(response.headers["content-type"]).toEqual(expect.stringContaining("application/json"));
14+
});
15+
16+
it("should response with 201 when new pet created with all the fields", async () => {
17+
const response = await request(app).post("/api/pet").send({
18+
id: 5,
19+
name: "Sandy",
20+
type: "Hamster"
21+
});
22+
23+
expect(response.statusCode).toBe(201);
24+
});
25+
26+
it("should be content type of json in the header when a new pet is added", async () => {
27+
const response = await request(app).post("/api/pet").send({
28+
id: 5,
29+
name: "Sandy",
30+
type: "Hamster"
31+
});
32+
33+
expect(response.headers["content-type"]).toEqual(expect.stringContaining("application/json"));
34+
});
35+
});
36+
});

0 commit comments

Comments
 (0)