Skip to content

Commit e3552c6

Browse files
committed
Added validator test
1 parent 3e4ad3a commit e3552c6

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

test/unit/middlewares/qrCodeAuthValidator.test.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
const Sinon = require("sinon");
2-
const { validateAuthStatus, storeUserDeviceInfo } = require("../../../middlewares/validators/qrCodeAuth");
2+
const {
3+
validateAuthStatus,
4+
storeUserDeviceInfo,
5+
validateFetchingUserDocument,
6+
} = require("../../../middlewares/validators/qrCodeAuth");
37
const { expect } = require("chai");
48
const { userDeviceInfoDataArray } = require("../../fixtures/qrCodeAuth/qrCodeAuth");
59
describe("qrCodeAuth", function () {
@@ -65,4 +69,39 @@ describe("qrCodeAuth", function () {
6569
expect(nextSpy.callCount).to.be.equal(0);
6670
});
6771
});
72+
73+
describe("test get call validator", function () {
74+
it("Allows request to pass on valid params", async function () {
75+
const req = {
76+
query: {
77+
device_id: "DEVICE_ID",
78+
},
79+
};
80+
81+
const res = {};
82+
83+
const nextSpy = Sinon.spy();
84+
await validateFetchingUserDocument(req, res, nextSpy);
85+
expect(nextSpy.callCount).to.be.equal(1);
86+
});
87+
88+
it("Does not allow request to pass on invalid params", async function () {
89+
const req = {
90+
query: {
91+
user_id: "ID",
92+
device_type: "DEVICE_TYPE",
93+
},
94+
};
95+
96+
const res = {
97+
boom: {
98+
badRequest: () => {},
99+
},
100+
};
101+
102+
const nextSpy = Sinon.spy();
103+
await validateFetchingUserDocument(req, res, nextSpy);
104+
expect(nextSpy.callCount).to.be.equal(0);
105+
});
106+
});
68107
});

0 commit comments

Comments
 (0)