Skip to content

Commit b71f3b2

Browse files
committed
fix: test case
1 parent db1c78b commit b71f3b2

File tree

4 files changed

+119
-133
lines changed

4 files changed

+119
-133
lines changed

test/fixtures/oooRequest/oooRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const createOooRequests3 = {
164164
from: Date.now() + 100000,
165165
until: Date.now() + 200000,
166166
type: "OOO",
167-
requestedBy: "testUser",
167+
requestedBy: "suraj-maity-1",
168168
reason: "Out of office for personal emergency.",
169169
status: REQUEST_STATE.PENDING
170170
};

test/integration/requests.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import chai from "chai";
22
const { expect } = chai;
3-
import sinon from "sinon";
43
import chaiHttp from "chai-http";
54
import _ from "lodash";
65
import config from "config";
@@ -30,7 +29,8 @@ import {
3029
REQUEST_ALREADY_PENDING,
3130
REQUEST_REJECTED_SUCCESSFULLY,
3231
REQUEST_ALREADY_REJECTED,
33-
// UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST,
32+
INVALID_REQUEST_TYPE,
33+
UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST,
3434
// UNAUTHORIZED_TO_CREATE_OOO_REQUEST,
3535
// USER_STATUS_NOT_FOUND,
3636
// OOO_STATUS_ALREADY_EXIST,
@@ -40,6 +40,7 @@ import { validTaskAssignmentRequest, validTaskCreqtionRequest } from "../fixture
4040
import { deleteUserStatus, updateUserStatus } from "../../models/userStatus";
4141
import * as requestsQuery from "../../models/requests";
4242
import { userState } from "../../constants/userStatus";
43+
import * as logUtils from "../../services/logService";
4344

4445
const userData = userDataFixture();
4546
chai.use(chaiHttp);
@@ -55,7 +56,7 @@ let testUserId: string;
5556
let testSuperUserId: string;
5657
let testArchivedUserId: string;
5758

58-
describe("/requests OOO", function () {
59+
describe.only("/requests OOO", function () {
5960

6061
const requestsEndpoint: string = "/requests?dev=true";
6162

@@ -322,15 +323,15 @@ describe("/requests OOO", function () {
322323
});
323324
});
324325

325-
describe.skip("PATCH /requests/:id", function () {
326+
describe("PATCH /requests/:id", function () {
326327
let pendingOooRequestId1: string;
327328
let oooRequestData3: any;
328329
let invalidRequestId: string;
329330
let approvedOooRequestId: string;
330331
let rejectedOooRequestId: string;
331332

332333
beforeEach(async function () {
333-
oooRequestData3 = { ...createOooRequests3, requestedBy: testUserId };
334+
oooRequestData3 = { ...createOooRequests3, userId: testUserId };
334335

335336
const { id: pendingOooId1 }: any = await createRequest(oooRequestData3);
336337
pendingOooRequestId1 = pendingOooId1;
@@ -394,7 +395,7 @@ describe("/requests OOO", function () {
394395
});
395396
});
396397

397-
it("should return 401 if user does not have super user permission", function (done) {
398+
it("should return 403 if user does not have super user permission", function (done) {
398399
chai
399400
.request(app)
400401
.patch(`/requests/${pendingOooRequestId1}?dev=true`)
@@ -404,13 +405,13 @@ describe("/requests OOO", function () {
404405
if (err) {
405406
return done(err);
406407
}
407-
expect(res.statusCode).to.equal(401);
408-
// expect(res.body.message).to.equal(UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST);
408+
expect(res.statusCode).to.equal(403);
409+
expect(res.body.message).to.equal(UNAUTHORIZED_TO_ACKNOWLEDGE_OOO_REQUEST);
409410
done();
410411
});
411412
});
412413

413-
it("should return 400 if OOO request is already approved", function (done) {
414+
it("should return 409 if OOO request is already approved", function (done) {
414415
chai
415416
.request(app)
416417
.patch(`/requests/${approvedOooRequestId}?dev=true`)
@@ -420,13 +421,13 @@ describe("/requests OOO", function () {
420421
if (err) {
421422
return done(err);
422423
}
423-
expect(res.statusCode).to.equal(400);
424+
expect(res.statusCode).to.equal(409);
424425
expect(res.body.message).to.equal(REQUEST_ALREADY_APPROVED);
425426
done();
426427
});
427428
});
428429

429-
it("should return 400 if OOO request is already rejected", function (done) {
430+
it("should return 409 if OOO request is already rejected", function (done) {
430431
chai
431432
.request(app)
432433
.patch(`/requests/${rejectedOooRequestId}?dev=true`)
@@ -436,7 +437,7 @@ describe("/requests OOO", function () {
436437
if (err) {
437438
return done(err);
438439
}
439-
expect(res.statusCode).to.equal(400);
440+
expect(res.statusCode).to.equal(409);
440441
expect(res.body.message).to.equal(REQUEST_ALREADY_REJECTED);
441442
done();
442443
});

test/unit/middlewares/oooRequests.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { expect } = chai;
44

55
import {
66
createOooStatusRequestValidator,
7-
// acknowledgeOOORequestsValidator,
7+
acknowledgeOOORequestsValidator,
88
} from "./../../../middlewares/validators/oooRequests";
99
import { acknowledgeOooRequest, validOooStatusRequests, validOooStatusUpdate } from "../../fixtures/oooRequest/oooRequest";
1010
import _ from "lodash";
@@ -93,39 +93,39 @@ describe("OOO Status Request Validators", function () {
9393
});
9494

9595
describe("acknowledgeOOORequestsValidator", function () {
96-
it.skip("should not validate for an invalid request for invalid request type", async function () {
96+
it("should not validate for an invalid request for invalid request type", async function () {
9797
req = {
9898
body: { ...acknowledgeOooRequest, type: "XYZ"}
9999
};
100100

101-
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
101+
await acknowledgeOOORequestsValidator(req, res, nextSpy);
102102
expect(nextSpy.notCalled).to.be.true;
103103
});
104104

105-
it.skip("should not validate for an invalid request if status is incorrect", async function () {
105+
it("should not validate for an invalid request if status is incorrect", async function () {
106106
req = {
107107
body: { ...acknowledgeOooRequest, status: "PENDING"}
108108
};
109109

110-
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
110+
await acknowledgeOOORequestsValidator(req, res, nextSpy);
111111
expect(nextSpy.notCalled).to.be.true;
112112
});
113113

114-
it.skip("should validate for a valid acknowledge OOO request if comment not provided by superusers", async function() {
114+
it("should validate for a valid acknowledge OOO request if comment not provided by superusers", async function() {
115115
req = {
116116
body: _.omit(acknowledgeOooRequest, "comment")
117117
};
118118
res = {};
119-
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
119+
await acknowledgeOOORequestsValidator(req, res, nextSpy);
120120
expect(nextSpy.calledOnce).to.be.true;
121121
});
122122

123-
it.skip("should validate for a valid acknowledge OOO request", async function() {
123+
it("should validate for a valid acknowledge OOO request", async function() {
124124
req = {
125125
body: acknowledgeOooRequest
126126
};
127127
res = {};
128-
// await acknowledgeOOORequestsValidator(req, res, nextSpy);
128+
await acknowledgeOOORequestsValidator(req, res, nextSpy);
129129
expect(nextSpy.calledOnce).to.be.true;
130130
});
131131
});

0 commit comments

Comments
 (0)