Skip to content

Commit ea2860d

Browse files
committed
fixed the test case and and added a new test case for the API
1 parent 5d8d93f commit ea2860d

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

test/integration/taskRequests.test.js

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ describe("Task Requests", function () {
176176
});
177177
});
178178

179+
it("should return 404 if the task request is not found for the given Id", function (done) {
180+
chai
181+
.request(app)
182+
.get(`/taskRequests/1234`)
183+
.set("cookie", `${cookieName}=${jwt}`)
184+
.end((err, res) => {
185+
if (err) {
186+
return done(err);
187+
}
188+
189+
expect(res).to.have.status(404);
190+
expect(res.body.message).to.be.equal("Task request not found");
191+
return done();
192+
});
193+
});
194+
179195
it("should return 404 if the resource is not found", function (done) {
180196
sinon.stub(taskRequestsModel, "fetchTaskRequestById").callsFake(() => []);
181197

@@ -196,21 +212,26 @@ describe("Task Requests", function () {
196212
});
197213

198214
describe("When the user is not a super user", function () {
215+
let taskrequestid;
216+
199217
before(async function () {
200218
userId = await addUser(member);
201-
sinon.stub(authService, "verifyAuthToken").callsFake(() => ({ userId }));
202-
jwt = authService.generateAuthToken({ userId });
219+
sinon.stub(authService, "verifyAuthToken").callsFake(() => ({
220+
userId,
221+
}));
222+
jwt = authService.generateAuthToken({
223+
userId,
224+
});
203225

204226
taskId = (await tasksModel.updateTask(taskData[4])).taskId;
205-
206227
await userStatusModel.updateUserStatus(userId, idleUserStatus);
207-
await taskRequestsModel.addOrUpdate(taskId, userId);
228+
taskrequestid = (await taskRequestsModel.addOrUpdate(taskId, userId)).id;
208229
});
209230

210231
it("should be successful when the user is not a super user", function (done) {
211232
chai
212233
.request(app)
213-
.get(`/taskRequests/taskrequstid`)
234+
.get(`/taskRequests/${taskrequestid}`)
214235
.set("cookie", `${cookieName}=${jwt}`)
215236
.end((err, res) => {
216237
if (err) {

0 commit comments

Comments
 (0)