Skip to content

Commit 3ed067c

Browse files
committed
Isolated test cases
1 parent a247be2 commit 3ed067c

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

test/test.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ logger.turnOffConsoleLogging();
1212
describe(`API Tests`, function () {
1313
let userToken;
1414
let adminToken;
15+
let messageId1;
16+
let messageId2;
17+
let blogId1;
18+
let blogId2;
1519
this.timeout(30000);
1620
before(async () => {
1721
logger.info("Tests starting:");
@@ -28,6 +32,36 @@ describe(`API Tests`, function () {
2832
});
2933
adminToken = adminResult.body.access;
3034
// console.log("adminToken: ", adminToken);
35+
const message1Result = await chai.request(app).post("/messages").type("json").send({
36+
name: "Main Name 1",
37+
38+
message: "Test Message",
39+
});
40+
messageId1 = message1Result.body.newMessage._id;
41+
const message2Result = await chai.request(app).post("/messages").type("json").send({
42+
name: "Main Name 2",
43+
44+
message: "Test Message",
45+
});
46+
messageId2 = message2Result.body.newMessage._id;
47+
const blog1Result = await chai
48+
.request(app)
49+
.post("/blogs")
50+
.type("json")
51+
.send({
52+
title: "Title 1",
53+
})
54+
.set("Authorization", `Bearer ${userToken}`);
55+
blogId1 = blog1Result.body.blog._id;
56+
const blog2Result = await chai
57+
.request(app)
58+
.post("/blogs")
59+
.type("json")
60+
.send({
61+
title: "Title 2",
62+
})
63+
.set("Authorization", `Bearer ${userToken}`);
64+
blogId2 = blog2Result.body.blog._id;
3165
});
3266
after(async () => {
3367
await chai
@@ -43,7 +77,7 @@ describe(`API Tests`, function () {
4377
await disconnectDB();
4478
logger.info("Testing ends");
4579
});
46-
describe(`Tests on "/users"`, function () {
80+
describe.skip(`Tests on "/users"`, function () {
4781
describe(`Correct Input Tests`, function () {
4882
it(`[201 | NoAuth | POST "/users/register" | Correct Inputs ]`, (done) => {
4983
chai.request(app)
@@ -532,9 +566,7 @@ describe(`API Tests`, function () {
532566
});
533567
});
534568
});
535-
describe(`Tests on "/messages"`, function () {
536-
let messageId1;
537-
let messageId2;
569+
describe.skip(`Tests on "/messages"`, function () {
538570
describe(`Correct Input Tests`, function () {
539571
it(`[200 | Admin | GET "/messages" | ]`, (done) => {
540572
chai.request(app)
@@ -562,7 +594,6 @@ describe(`API Tests`, function () {
562594
chai.expect(res.body).to.have.property("success").that.equals(true);
563595
chai.expect(res.body).to.have.property("message").that.equals("Message created.");
564596
chai.expect(res.body).to.have.property("newMessage").that.is.a("object");
565-
messageId1 = res.body.newMessage._id;
566597
done();
567598
});
568599
});
@@ -581,7 +612,6 @@ describe(`API Tests`, function () {
581612
chai.expect(res.body).to.have.property("success").that.equals(true);
582613
chai.expect(res.body).to.have.property("message").that.equals("Message created.");
583614
chai.expect(res.body).to.have.property("newMessage").that.is.a("object");
584-
messageId2 = res.body.newMessage._id;
585615
done();
586616
});
587617
});

0 commit comments

Comments
 (0)