fix: revert tests
This commit is contained in:
1 parent
dea8c4fdd8
commit
08933743f1
11 files changed
+69
-97
No files matched your search
@@ -18,8 +18,6 @@ import { getTokenFromHeaders, tokenType } from "../../utils/utils.js";
|
|||||||
import logger from "../../utils/logger.js";
|
import logger from "../../utils/logger.js";
|
||||||
import e from "cors";
|
import e from "cors";
|
||||||
|
|
||||||
const mockLanguage = 'en';
|
|
||||||
|
|
||||||
describe("Auth Controller - issueToken", function() {
|
describe("Auth Controller - issueToken", function() {
|
||||||
let stub;
|
let stub;
|
||||||
|
|
||||||
@@ -204,7 +202,7 @@ describe("Auth Controller - registerUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_CREATE_USER(mockLanguage),
|
msg: successMessages.AUTH_CREATE_USER,
|
||||||
data: { user, token: sinon.match.string, refreshToken: sinon.match.string },
|
data: { user, token: sinon.match.string, refreshToken: sinon.match.string },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -226,7 +224,7 @@ describe("Auth Controller - registerUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_CREATE_USER(mockLanguage),
|
msg: successMessages.AUTH_CREATE_USER,
|
||||||
data: { user, token: sinon.match.string, refreshToken: sinon.match.string },
|
data: { user, token: sinon.match.string, refreshToken: sinon.match.string },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -243,7 +241,6 @@ describe("Auth Controller - loginUser", function () {
|
|||||||
db: {
|
db: {
|
||||||
getUserByEmail: sinon.stub(),
|
getUserByEmail: sinon.stub(),
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
settingsService: {
|
settingsService: {
|
||||||
getSettings: sinon.stub().resolves({
|
getSettings: sinon.stub().resolves({
|
||||||
jwtSecret: "my_secret",
|
jwtSecret: "my_secret",
|
||||||
@@ -286,7 +283,7 @@ describe("Auth Controller - loginUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_LOGIN_USER(mockLanguage),
|
msg: successMessages.AUTH_LOGIN_USER,
|
||||||
data: {
|
data: {
|
||||||
user: {
|
user: {
|
||||||
email: "test@example.com",
|
email: "test@example.com",
|
||||||
@@ -310,7 +307,7 @@ describe("Auth Controller - loginUser", function () {
|
|||||||
await loginUser(req, res, next);
|
await loginUser(req, res, next);
|
||||||
expect(next.firstCall.args[0]).to.be.an("error");
|
expect(next.firstCall.args[0]).to.be.an("error");
|
||||||
expect(next.firstCall.args[0].message).to.equal(
|
expect(next.firstCall.args[0].message).to.equal(
|
||||||
errorMessages.AUTH_INCORRECT_PASSWORD(mockLanguage)
|
errorMessages.AUTH_INCORRECT_PASSWORD
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -351,7 +348,7 @@ describe("Auth Controller - refreshAuthToken", function () {
|
|||||||
await refreshAuthToken(req, res, next);
|
await refreshAuthToken(req, res, next);
|
||||||
|
|
||||||
expect(next.firstCall.args[0]).to.be.an("error");
|
expect(next.firstCall.args[0]).to.be.an("error");
|
||||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.NO_REFRESH_TOKEN(req.language));
|
expect(next.firstCall.args[0].message).to.equal(errorMessages.NO_REFRESH_TOKEN);
|
||||||
expect(next.firstCall.args[0].status).to.equal(401);
|
expect(next.firstCall.args[0].status).to.equal(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -360,7 +357,7 @@ describe("Auth Controller - refreshAuthToken", function () {
|
|||||||
await refreshAuthToken(req, res, next);
|
await refreshAuthToken(req, res, next);
|
||||||
|
|
||||||
expect(next.firstCall.args[0]).to.be.an("error");
|
expect(next.firstCall.args[0]).to.be.an("error");
|
||||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.INVALID_REFRESH_TOKEN(req.language));
|
expect(next.firstCall.args[0].message).to.equal(errorMessages.INVALID_REFRESH_TOKEN);
|
||||||
expect(next.firstCall.args[0].status).to.equal(401);
|
expect(next.firstCall.args[0].status).to.equal(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -370,7 +367,7 @@ describe("Auth Controller - refreshAuthToken", function () {
|
|||||||
jwt.verify.yields(error);
|
jwt.verify.yields(error);
|
||||||
await refreshAuthToken(req, res, next);
|
await refreshAuthToken(req, res, next);
|
||||||
expect(next.firstCall.args[0]).to.be.an("error");
|
expect(next.firstCall.args[0]).to.be.an("error");
|
||||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.EXPIRED_REFRESH_TOKEN(req.language));
|
expect(next.firstCall.args[0].message).to.equal(errorMessages.EXPIRED_REFRESH_TOKEN);
|
||||||
expect(next.firstCall.args[0].status).to.equal(401);
|
expect(next.firstCall.args[0].status).to.equal(401);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -395,7 +392,7 @@ describe("Auth Controller - refreshAuthToken", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_TOKEN_REFRESHED(mockLanguage),
|
msg: successMessages.AUTH_TOKEN_REFRESHED,
|
||||||
data: {
|
data: {
|
||||||
user: decodedPayload,
|
user: decodedPayload,
|
||||||
token: sinon.match.string,
|
token: sinon.match.string,
|
||||||
@@ -481,7 +478,7 @@ describe("Auth Controller - editUser", function () {
|
|||||||
expect(next.firstCall.args[0]).to.be.an("error");
|
expect(next.firstCall.args[0]).to.be.an("error");
|
||||||
expect(next.firstCall.args[0].status).to.equal(401);
|
expect(next.firstCall.args[0].status).to.equal(401);
|
||||||
expect(next.firstCall.args[0].message).to.equal(
|
expect(next.firstCall.args[0].message).to.equal(
|
||||||
errorMessages.AUTH_INCORRECT_PASSWORD(mockLanguage)
|
errorMessages.AUTH_INCORRECT_PASSWORD
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -500,7 +497,7 @@ describe("Auth Controller - editUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_UPDATE_USER(mockLanguage),
|
msg: successMessages.AUTH_UPDATE_USER,
|
||||||
data: { email: "test@example.com" },
|
data: { email: "test@example.com" },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -518,7 +515,7 @@ describe("Auth Controller - editUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_UPDATE_USER(mockLanguage),
|
msg: successMessages.AUTH_UPDATE_USER,
|
||||||
data: { email: "test@example.com" },
|
data: { email: "test@example.com" },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -569,7 +566,7 @@ describe("Auth Controller - checkSuperadminExists", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_SUPERADMIN_EXISTS(mockLanguage),
|
msg: successMessages.AUTH_SUPERADMIN_EXISTS,
|
||||||
data: true,
|
data: true,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -583,7 +580,7 @@ describe("Auth Controller - checkSuperadminExists", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_SUPERADMIN_EXISTS(mockLanguage),
|
msg: successMessages.AUTH_SUPERADMIN_EXISTS,
|
||||||
data: false,
|
data: false,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -671,7 +668,7 @@ describe("Auth Controller - requestRecovery", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_CREATE_RECOVERY_TOKEN(mockLanguage),
|
msg: successMessages.AUTH_CREATE_RECOVERY_TOKEN,
|
||||||
data: msgId,
|
data: msgId,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -717,7 +714,7 @@ describe("Auth Controller - validateRecovery", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_VERIFY_RECOVERY_TOKEN(mockLanguage),
|
msg: successMessages.AUTH_VERIFY_RECOVERY_TOKEN,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(next.notCalled).to.be.true;
|
expect(next.notCalled).to.be.true;
|
||||||
@@ -785,7 +782,7 @@ describe("Auth Controller - resetPassword", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_RESET_PASSWORD(mockLanguage),
|
msg: successMessages.AUTH_RESET_PASSWORD,
|
||||||
data: { user: sinon.match.object, token: sinon.match.string },
|
data: { user: sinon.match.object, token: sinon.match.string },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -834,13 +831,13 @@ describe("Auth Controller - deleteUser", function () {
|
|||||||
|
|
||||||
it("should throw an error if user is not found", async function() {
|
it("should throw an error if user is not found", async function() {
|
||||||
jwt.decode.returns({ email: "test@example.com" });
|
jwt.decode.returns({ email: "test@example.com" });
|
||||||
req.db.getUserByEmail.throws(new Error(errorMessages.DB_USER_NOT_FOUND(req.language)));
|
req.db.getUserByEmail.throws(new Error(errorMessages.DB_USER_NOT_FOUND));
|
||||||
|
|
||||||
await deleteUser(req, res, next);
|
await deleteUser(req, res, next);
|
||||||
|
|
||||||
expect(req.db.getUserByEmail.calledOnceWith("test@example.com")).to.be.true;
|
expect(req.db.getUserByEmail.calledOnceWith("test@example.com")).to.be.true;
|
||||||
expect(next.calledOnce).to.be.true;
|
expect(next.calledOnce).to.be.true;
|
||||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.DB_USER_NOT_FOUND(req.language));
|
expect(next.firstCall.args[0].message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
expect(res.status.notCalled).to.be.true;
|
expect(res.status.notCalled).to.be.true;
|
||||||
expect(res.json.notCalled).to.be.true;
|
expect(res.json.notCalled).to.be.true;
|
||||||
});
|
});
|
||||||
@@ -879,7 +876,7 @@ describe("Auth Controller - deleteUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_DELETE_USER(mockLanguage),
|
msg: successMessages.AUTH_DELETE_USER,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(next.notCalled).to.be.true;
|
expect(next.notCalled).to.be.true;
|
||||||
@@ -909,7 +906,7 @@ describe("Auth Controller - deleteUser", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.AUTH_DELETE_USER(mockLanguage),
|
msg: successMessages.AUTH_DELETE_USER,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(next.notCalled).to.be.true;
|
expect(next.notCalled).to.be.true;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ describe("Check Controller - createCheck", function () {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
req = {
|
req = {
|
||||||
language: 'en',
|
|
||||||
params: {},
|
params: {},
|
||||||
body: {},
|
body: {},
|
||||||
db: {
|
db: {
|
||||||
@@ -81,7 +80,7 @@ describe("Check Controller - createCheck", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_CREATE(req.language),
|
msg: successMessages.CHECK_CREATE,
|
||||||
data: { id: "123" },
|
data: { id: "123" },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -129,7 +128,7 @@ describe("Check Controller - getChecks", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledWith({
|
res.json.calledWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_GET(req.language),
|
msg: successMessages.CHECK_GET,
|
||||||
data: { checksCount: 1, checks: [{ id: "123" }] },
|
data: { checksCount: 1, checks: [{ id: "123" }] },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -185,7 +184,7 @@ describe("Check Controller - getTeamChecks", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_GET(req.language),
|
msg: successMessages.CHECK_GET,
|
||||||
data: checkData,
|
data: checkData,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -248,7 +247,7 @@ describe("Check Controller - deleteChecks", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_DELETE(req.language),
|
msg: successMessages.CHECK_DELETE,
|
||||||
data: { deletedCount: 1 },
|
data: { deletedCount: 1 },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -301,7 +300,7 @@ describe("Check Controller - deleteChecksByTeamId", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_DELETE(req.language),
|
msg: successMessages.CHECK_DELETE,
|
||||||
data: { deletedCount: 1 },
|
data: { deletedCount: 1 },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -373,7 +372,7 @@ describe("Check Controller - updateCheckTTL", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.CHECK_UPDATE_TTL(req.language),
|
msg: successMessages.CHECK_UPDATE_TTL,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ describe("maintenanceWindowController - createMaintenanceWindows", function () {
|
|||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
req = {
|
req = {
|
||||||
language: 'en',
|
|
||||||
body: {
|
body: {
|
||||||
monitors: ["66ff52e7c5911c61698ac724"],
|
monitors: ["66ff52e7c5911c61698ac724"],
|
||||||
name: "window",
|
name: "window",
|
||||||
@@ -84,7 +83,7 @@ describe("maintenanceWindowController - createMaintenanceWindows", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_CREATE(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_CREATE,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
stub.restore();
|
stub.restore();
|
||||||
@@ -100,7 +99,7 @@ describe("maintenanceWindowController - createMaintenanceWindows", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_CREATE(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_CREATE,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
stub.restore();
|
stub.restore();
|
||||||
@@ -122,7 +121,6 @@ describe("maintenanceWindowController - getMaintenanceWindowById", function () {
|
|||||||
settingsService: {
|
settingsService: {
|
||||||
getSettings: sinon.stub().returns({ jwtSecret: "jwtSecret" }),
|
getSettings: sinon.stub().returns({ jwtSecret: "jwtSecret" }),
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMaintenanceWindowById: sinon.stub(),
|
getMaintenanceWindowById: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -155,7 +153,7 @@ describe("maintenanceWindowController - getMaintenanceWindowById", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_ID(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_ID,
|
||||||
data: { id: "123" },
|
data: { id: "123" },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -179,7 +177,6 @@ describe("maintenanceWindowController - getMaintenanceWindowsByTeamId", function
|
|||||||
db: {
|
db: {
|
||||||
getMaintenanceWindowsByTeamId: sinon.stub(),
|
getMaintenanceWindowsByTeamId: sinon.stub(),
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
};
|
};
|
||||||
res = {
|
res = {
|
||||||
status: sinon.stub().returnsThis(),
|
status: sinon.stub().returnsThis(),
|
||||||
@@ -225,7 +222,7 @@ describe("maintenanceWindowController - getMaintenanceWindowsByTeamId", function
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_TEAM(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_TEAM,
|
||||||
data: [{ id: jwt.verify().teamId }],
|
data: [{ id: jwt.verify().teamId }],
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -287,7 +284,7 @@ describe("maintenanceWindowController - getMaintenanceWindowsByMonitorId", funct
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_MONITOR(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_GET_BY_MONITOR,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -346,7 +343,7 @@ describe("maintenanceWindowController - deleteMaintenanceWindow", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_DELETE(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_DELETE,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
});
|
});
|
||||||
@@ -361,7 +358,6 @@ describe("maintenanceWindowController - editMaintenanceWindow", function () {
|
|||||||
active: true,
|
active: true,
|
||||||
name: "test",
|
name: "test",
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
params: {
|
params: {
|
||||||
id: "123",
|
id: "123",
|
||||||
},
|
},
|
||||||
@@ -418,7 +414,7 @@ describe("maintenanceWindowController - editMaintenanceWindow", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MAINTENANCE_WINDOW_EDIT(req.language),
|
msg: successMessages.MAINTENANCE_WINDOW_EDIT,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import sinon from "sinon";
|
|||||||
import { successMessages } from "../../utils/messages.js";
|
import { successMessages } from "../../utils/messages.js";
|
||||||
import logger from "../../utils/logger.js";
|
import logger from "../../utils/logger.js";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
const SERVICE_NAME = "monitorController";
|
||||||
|
|
||||||
describe("Monitor Controller - getAllMonitors", function() {
|
describe("Monitor Controller - getAllMonitors", function() {
|
||||||
let req, res, next;
|
let req, res, next;
|
||||||
@@ -28,7 +29,6 @@ describe("Monitor Controller - getAllMonitors", function () {
|
|||||||
params: {},
|
params: {},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getAllMonitors: sinon.stub(),
|
getAllMonitors: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -59,7 +59,7 @@ describe("Monitor Controller - getAllMonitors", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_ALL(req.language),
|
msg: successMessages.MONITOR_GET_ALL,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -73,7 +73,6 @@ describe("Monitor Controller - getAllMonitorsWithUptimeStats", function () {
|
|||||||
params: {},
|
params: {},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getAllMonitorsWithUptimeStats: sinon.stub(),
|
getAllMonitorsWithUptimeStats: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -104,7 +103,7 @@ describe("Monitor Controller - getAllMonitorsWithUptimeStats", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_ALL(req.language),
|
msg: successMessages.MONITOR_GET_ALL,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -121,7 +120,6 @@ describe("Monitor Controller - getMonitorStatsById", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorStatsById: sinon.stub(),
|
getMonitorStatsById: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -166,7 +164,7 @@ describe("Monitor Controller - getMonitorStatsById", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_STATS_BY_ID(req.language),
|
msg: successMessages.MONITOR_STATS_BY_ID,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -183,7 +181,6 @@ describe("Monitor Controller - getMonitorCertificate", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorById: sinon.stub(),
|
getMonitorById: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -223,7 +220,7 @@ describe("Monitor Controller - getMonitorCertificate", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_CERTIFICATE(req.language),
|
msg: successMessages.MONITOR_CERTIFICATE,
|
||||||
data: { certificateDate: new Date(data.validTo) },
|
data: { certificateDate: new Date(data.validTo) },
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -248,7 +245,6 @@ describe("Monitor Controller - getMonitorById", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorById: sinon.stub(),
|
getMonitorById: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -302,7 +298,7 @@ describe("Monitor Controller - getMonitorById", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_BY_ID(req.language),
|
msg: successMessages.MONITOR_GET_BY_ID,
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -319,7 +315,6 @@ describe("Monitor Controller - getMonitorsAndSummaryByTeamId", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorsAndSummaryByTeamId: sinon.stub(),
|
getMonitorsAndSummaryByTeamId: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -364,7 +359,7 @@ describe("Monitor Controller - getMonitorsAndSummaryByTeamId", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_BY_USER_ID(req.params.teamId, req.language),
|
msg: successMessages.MONITOR_GET_BY_USER_ID(req.params.teamId),
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -381,7 +376,6 @@ describe("Monitor Controller - getMonitorsByTeamId", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorsByTeamId: sinon.stub(),
|
getMonitorsByTeamId: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -426,7 +420,7 @@ describe("Monitor Controller - getMonitorsByTeamId", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_BY_USER_ID(req.params.teamId, req.language),
|
msg: successMessages.MONITOR_GET_BY_USER_ID(req.params.teamId),
|
||||||
data: data,
|
data: data,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -449,7 +443,6 @@ describe("Monitor Controller - createMonitor", function () {
|
|||||||
url: "https://example.com",
|
url: "https://example.com",
|
||||||
notifications: [{ email: "example@example.com" }],
|
notifications: [{ email: "example@example.com" }],
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
createMonitor: sinon.stub(),
|
createMonitor: sinon.stub(),
|
||||||
createNotification: sinon.stub(),
|
createNotification: sinon.stub(),
|
||||||
@@ -517,7 +510,7 @@ describe("Monitor Controller - createMonitor", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_CREATE(req.language),
|
msg: successMessages.MONITOR_CREATE,
|
||||||
data: monitor,
|
data: monitor,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -587,7 +580,6 @@ describe("Monitor Controller - deleteMonitor", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
deleteMonitor: sinon.stub(),
|
deleteMonitor: sinon.stub(),
|
||||||
deleteChecks: sinon.stub(),
|
deleteChecks: sinon.stub(),
|
||||||
@@ -680,7 +672,7 @@ describe("Monitor Controller - deleteMonitor", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_DELETE(req.language),
|
msg: successMessages.MONITOR_DELETE,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
});
|
});
|
||||||
@@ -702,7 +694,6 @@ describe("Monitor Controller - deleteAllMonitors", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
deleteAllMonitors: sinon.stub(),
|
deleteAllMonitors: sinon.stub(),
|
||||||
deleteChecks: sinon.stub(),
|
deleteChecks: sinon.stub(),
|
||||||
@@ -793,14 +784,16 @@ describe("Monitor Controller - deleteAllMonitors", function () {
|
|||||||
|
|
||||||
it("should return success message if all operations succeed", async function() {
|
it("should return success message if all operations succeed", async function() {
|
||||||
req.settingsService.getSettings.returns({ jwtSecret: "my_secret" });
|
req.settingsService.getSettings.returns({ jwtSecret: "my_secret" });
|
||||||
const { monitors, deletedCount } = { monitors: [{ name: "test_monitor", _id: "123" }], deletedCount: 1 };
|
req.db.deleteAllMonitors.returns({
|
||||||
req.db.deleteAllMonitors.returns({ monitors, deletedCount });
|
monitors: [{ name: "test_monitor", _id: "123" }],
|
||||||
|
deletedCount: 1,
|
||||||
|
});
|
||||||
await deleteAllMonitors(req, res, next);
|
await deleteAllMonitors(req, res, next);
|
||||||
expect(res.status.firstCall.args[0]).to.equal(200);
|
expect(res.status.firstCall.args[0]).to.equal(200);
|
||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: `Deleted ${deletedCount} monitors`,
|
msg: "Deleted 1 monitors",
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
});
|
});
|
||||||
@@ -819,7 +812,6 @@ describe("Monitor Controller - editMonitor", function () {
|
|||||||
body: {
|
body: {
|
||||||
notifications: [{ email: "example@example.com" }],
|
notifications: [{ email: "example@example.com" }],
|
||||||
},
|
},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorById: sinon.stub(),
|
getMonitorById: sinon.stub(),
|
||||||
editMonitor: sinon.stub(),
|
editMonitor: sinon.stub(),
|
||||||
@@ -919,7 +911,7 @@ describe("Monitor Controller - editMonitor", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_EDIT(req.language),
|
msg: successMessages.MONITOR_EDIT,
|
||||||
data: monitor,
|
data: monitor,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -937,7 +929,6 @@ describe("Monitor Controller - pauseMonitor", function () {
|
|||||||
},
|
},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
getMonitorById: sinon.stub(),
|
getMonitorById: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -1016,7 +1007,7 @@ describe("Monitor Controller - pauseMonitor", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_PAUSE(req.language),
|
msg: successMessages.MONITOR_PAUSE,
|
||||||
data: monitor,
|
data: monitor,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -1034,7 +1025,7 @@ describe("Monitor Controller - pauseMonitor", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_RESUME(req.language),
|
msg: successMessages.MONITOR_RESUME,
|
||||||
data: monitor,
|
data: monitor,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
@@ -1055,7 +1046,6 @@ describe("Monitor Controller - addDemoMonitors", function () {
|
|||||||
params: {},
|
params: {},
|
||||||
query: {},
|
query: {},
|
||||||
body: {},
|
body: {},
|
||||||
language: 'en',
|
|
||||||
db: {
|
db: {
|
||||||
addDemoMonitors: sinon.stub(),
|
addDemoMonitors: sinon.stub(),
|
||||||
},
|
},
|
||||||
@@ -1126,7 +1116,7 @@ describe("Monitor Controller - addDemoMonitors", function () {
|
|||||||
expect(
|
expect(
|
||||||
res.json.calledOnceWith({
|
res.json.calledOnceWith({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_DEMO_ADDED(req.language),
|
msg: successMessages.MONITOR_DEMO_ADDED,
|
||||||
data: monitors.length,
|
data: monitors.length,
|
||||||
})
|
})
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ describe("Invite Module", function () {
|
|||||||
role: ["admin"],
|
role: ["admin"],
|
||||||
token: "123",
|
token: "123",
|
||||||
};
|
};
|
||||||
const mockLanguage = 'en';
|
|
||||||
const mockInviteToken = { _id: 123, time: 123 };
|
const mockInviteToken = { _id: 123, time: 123 };
|
||||||
let inviteTokenDeleteManyStub,
|
let inviteTokenDeleteManyStub,
|
||||||
inviteTokenSaveStub,
|
inviteTokenSaveStub,
|
||||||
@@ -65,7 +64,7 @@ describe("Invite Module", function () {
|
|||||||
try {
|
try {
|
||||||
await getInviteToken(mockUserData.token);
|
await getInviteToken(mockUserData.token);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).to.equal(errorMessages.AUTH_INVITE_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.AUTH_INVITE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -93,7 +92,7 @@ describe("Invite Module", function () {
|
|||||||
try {
|
try {
|
||||||
await getInviteTokenAndDelete(mockUserData.token);
|
await getInviteTokenAndDelete(mockUserData.token);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).to.equal(errorMessages.AUTH_INVITE_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.AUTH_INVITE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1142,7 +1142,6 @@ describe("monitorModule", function () {
|
|||||||
it("should throw 404 error when monitor not found", async function() {
|
it("should throw 404 error when monitor not found", async function() {
|
||||||
// Arrange
|
// Arrange
|
||||||
const monitorId = "nonexistent";
|
const monitorId = "nonexistent";
|
||||||
const mockLanguage = 'en';
|
|
||||||
monitorFindByIdStub.resolves(null);
|
monitorFindByIdStub.resolves(null);
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
@@ -1150,7 +1149,7 @@ describe("monitorModule", function () {
|
|||||||
await getMonitorById(monitorId);
|
await getMonitorById(monitorId);
|
||||||
expect.fail("Should have thrown an error");
|
expect.fail("Should have thrown an error");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).to.equal(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId, mockLanguage));
|
expect(error.message).to.equal(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId));
|
||||||
expect(error.status).to.equal(404);
|
expect(error.status).to.equal(404);
|
||||||
expect(error.service).to.equal("monitorModule");
|
expect(error.service).to.equal("monitorModule");
|
||||||
expect(error.method).to.equal("getMonitorById");
|
expect(error.method).to.equal("getMonitorById");
|
||||||
@@ -1626,7 +1625,6 @@ describe("monitorModule", function () {
|
|||||||
const monitorId = "nonexistent123";
|
const monitorId = "nonexistent123";
|
||||||
const req = {
|
const req = {
|
||||||
params: { monitorId },
|
params: { monitorId },
|
||||||
language: 'en',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
monitorFindByIdAndDeleteStub.resolves(null);
|
monitorFindByIdAndDeleteStub.resolves(null);
|
||||||
@@ -1635,7 +1633,7 @@ describe("monitorModule", function () {
|
|||||||
await deleteMonitor(req);
|
await deleteMonitor(req);
|
||||||
expect.fail("Should have thrown an error");
|
expect.fail("Should have thrown an error");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
expect(err.message).to.equal(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId, req.language));
|
expect(err.message).to.equal(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId));
|
||||||
expect(err.service).to.equal("monitorModule");
|
expect(err.service).to.equal("monitorModule");
|
||||||
expect(err.method).to.equal("deleteMonitor");
|
expect(err.method).to.equal("deleteMonitor");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ describe("recoveryModule", function () {
|
|||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
req = {
|
req = {
|
||||||
body: { email: "test@test.com" },
|
body: { email: "test@test.com" },
|
||||||
language: 'en',
|
|
||||||
};
|
};
|
||||||
deleteManyStub = sinon.stub(RecoveryToken, "deleteMany");
|
deleteManyStub = sinon.stub(RecoveryToken, "deleteMany");
|
||||||
saveStub = sinon.stub(RecoveryToken.prototype, "save");
|
saveStub = sinon.stub(RecoveryToken.prototype, "save");
|
||||||
@@ -102,7 +101,7 @@ describe("recoveryModule", function () {
|
|||||||
await validateRecoveryToken(req, res);
|
await validateRecoveryToken(req, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND(req.language));
|
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -124,7 +123,6 @@ describe("recoveryModule", function () {
|
|||||||
password: "test",
|
password: "test",
|
||||||
newPassword: "test1",
|
newPassword: "test1",
|
||||||
};
|
};
|
||||||
req.language = 'en';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
@@ -137,7 +135,7 @@ describe("recoveryModule", function () {
|
|||||||
await resetPassword(req, res);
|
await resetPassword(req, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND(req.language));
|
expect(error.message).to.equal(errorMessages.DB_TOKEN_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -148,7 +146,7 @@ describe("recoveryModule", function () {
|
|||||||
await resetPassword(req, res);
|
await resetPassword(req, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND(req.language));
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -162,7 +160,7 @@ describe("recoveryModule", function () {
|
|||||||
await resetPassword(req, res);
|
await resetPassword(req, res);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.message).to.equal(errorMessages.DB_RESET_PASSWORD_BAD_MATCH(req.language));
|
expect(error.message).to.equal(errorMessages.DB_RESET_PASSWORD_BAD_MATCH);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import StatusPage from "../../db/models/StatusPage.js";
|
|||||||
import { errorMessages } from "../../utils/messages.js";
|
import { errorMessages } from "../../utils/messages.js";
|
||||||
|
|
||||||
describe("statusPageModule", function() {
|
describe("statusPageModule", function() {
|
||||||
let statusPageFindOneStub, statusPageSaveStub, statusPageFindStub, mockLanguage;
|
let statusPageFindOneStub, statusPageSaveStub, statusPageFindStub;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
mockLanguage = 'en';
|
|
||||||
statusPageSaveStub = sinon.stub(StatusPage.prototype, "save");
|
statusPageSaveStub = sinon.stub(StatusPage.prototype, "save");
|
||||||
statusPageFindOneStub = sinon.stub(StatusPage, "findOne");
|
statusPageFindOneStub = sinon.stub(StatusPage, "findOne");
|
||||||
statusPageFindStub = sinon.stub(StatusPage, "find");
|
statusPageFindStub = sinon.stub(StatusPage, "find");
|
||||||
@@ -27,7 +26,7 @@ describe("statusPageModule", function () {
|
|||||||
await createStatusPage({ url: "test" });
|
await createStatusPage({ url: "test" });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.status).to.equal(400);
|
expect(error.status).to.equal(400);
|
||||||
expect(error.message).to.equal(errorMessages.STATUS_PAGE_URL_NOT_UNIQUE(mockLanguage));
|
expect(error.message).to.equal(errorMessages.STATUS_PAGE_URL_NOT_UNIQUE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -59,14 +58,14 @@ describe("statusPageModule", function () {
|
|||||||
await getStatusPageByUrl("test");
|
await getStatusPageByUrl("test");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.status).to.equal(404);
|
expect(error.status).to.equal(404);
|
||||||
expect(error.message).to.equal(errorMessages.STATUS_PAGE_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.STATUS_PAGE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return a status page if a status page is found", async function() {
|
it("should return a status page if a status page is found", async function() {
|
||||||
const mockStatusPage = { url: "test" };
|
const mockStatusPage = { url: "test" };
|
||||||
statusPageFindOneStub.resolves(mockStatusPage);
|
statusPageFindOneStub.resolves(mockStatusPage);
|
||||||
const statusPage = await getStatusPageByUrl(mockStatusPage.url, mockLanguage);
|
const statusPage = await getStatusPageByUrl(mockStatusPage.url);
|
||||||
expect(statusPage).to.exist;
|
expect(statusPage).to.exist;
|
||||||
expect(statusPage).to.deep.equal(mockStatusPage);
|
expect(statusPage).to.deep.equal(mockStatusPage);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ const imageFile = {
|
|||||||
image: 1,
|
image: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockLanguage = 'en';
|
|
||||||
|
|
||||||
describe("userModule", function() {
|
describe("userModule", function() {
|
||||||
let teamSaveStub,
|
let teamSaveStub,
|
||||||
teamFindByIdAndDeleteStub,
|
teamFindByIdAndDeleteStub,
|
||||||
@@ -125,7 +123,7 @@ describe("userModule", function () {
|
|||||||
try {
|
try {
|
||||||
await getUserByEmail(mockUser.email);
|
await getUserByEmail(mockUser.email);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -208,7 +206,7 @@ describe("userModule", function () {
|
|||||||
await deleteUser("testId");
|
await deleteUser("testId");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).to.exist;
|
expect(error).to.exist;
|
||||||
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.DB_USER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ describe("Network Service", function () {
|
|||||||
try {
|
try {
|
||||||
await networkService.requestDocker(job);
|
await networkService.requestDocker(job);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).to.equal(errorMessages.DOCKER_NOT_FOUND(mockLanguage));
|
expect(error.message).to.equal(errorMessages.DOCKER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,16 +3,14 @@ describe("Messages", function () {
|
|||||||
describe("messages - errorMessages", function() {
|
describe("messages - errorMessages", function() {
|
||||||
it("should have a DB_FIND_MONITOR_BY_ID function", function() {
|
it("should have a DB_FIND_MONITOR_BY_ID function", function() {
|
||||||
const monitorId = "12345";
|
const monitorId = "12345";
|
||||||
const mockLanguage = 'en';
|
expect(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId)).to.equal(
|
||||||
expect(errorMessages.DB_FIND_MONITOR_BY_ID(monitorId, mockLanguage)).to.equal(
|
|
||||||
`Monitor with id ${monitorId} not found`
|
`Monitor with id ${monitorId} not found`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should have a DB_DELETE_CHECKS function", function() {
|
it("should have a DB_DELETE_CHECKS function", function() {
|
||||||
const monitorId = "12345";
|
const monitorId = "12345";
|
||||||
const mockLanguage = 'en';
|
expect(errorMessages.DB_DELETE_CHECKS(monitorId)).to.equal(
|
||||||
expect(errorMessages.DB_DELETE_CHECKS(monitorId, mockLanguage)).to.equal(
|
|
||||||
`No checks found for monitor with id ${monitorId}`
|
`No checks found for monitor with id ${monitorId}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user