Skip to content

Commit f2b922e

Browse files
committed
fixed testcase for tutorial, added timeout for testcases
1 parent ea81662 commit f2b922e

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const config = {
22
transform: {
33
},
4+
"testTimeout": 15000,
45
};
56

67
export default config;

test/routes/tutorial.test.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,38 @@ describe("checking tutorial functions", () => {
4444
expect(response.status).toBe(200);
4545
expect(response.body.res).toMatch(/added tutorial/);
4646
});
47-
48-
let tutorialId;
49-
beforeEach(async () => {
50-
const id = agent.post("/tutorial/add").send({
51-
no: "123",
52-
title: "abc",
53-
hours: "3",
54-
cognitiveLevel: ["L1", "L2"],
47+
48+
describe("after creating a practical", () => {
49+
let tutorialId;
50+
beforeEach(async () => {
51+
const id = await agent.post("/tutorial/add").send({
52+
no: "456",
53+
title: "dfg",
54+
hours: "3",
55+
cognitiveLevel: ["L1", "L2"],
56+
});
57+
tutorialId = JSON.parse(id.res.text).id;
5558
});
56-
tutorialId = JSON.parse(id.res.text).id;
57-
});
5859

59-
afterEach(async () => {
60-
await tutorialModel.remove({ no: "123" });
61-
});
60+
afterEach(async () => {
61+
await tutorialModel.remove();
62+
});
6263

63-
it("read tutorial", async () => {
64-
const response = await agent
65-
.get("/tutorial/list")
66-
.send({ name: "xyz" });
67-
expect(response.status).toBe(200);
68-
expect(response.body.res).toBeDefined();
69-
});
64+
it("read tutorial", async () => {
65+
const response = await agent
66+
.get("/tutorial/list")
67+
.send({ name: "dfg" });
68+
expect(response.status).toBe(200);
69+
expect(response.body.res).toBeDefined();
70+
});
7071

71-
it("update tutorial", async () => {
72-
const response = await agent
73-
.post(`/tutorial/update+${tutorialId}`)
74-
.send({ no: "123" }, { no: "123" });
75-
expect(response.headers["content-type"]).toMatch(/json/);
76-
expect(response.status).toBe(200);
77-
expect(response.body.res).toMatch(/tutorial updated/);
72+
it("update tutorial", async () => {
73+
const response = await agent
74+
.post(`/tutorial/update/${tutorialId}`)
75+
.send({ no: "456" });
76+
expect(response.headers["content-type"]).toMatch(/json/);
77+
expect(response.status).toBe(200);
78+
expect(response.body.res).toMatch(/tutorial updated/);
79+
});
7880
});
7981
});

0 commit comments

Comments
 (0)