format
This commit is contained in:
1 parent
846564a17e
commit
bfa6832beb
83 files changed
+338
-1249
No files matched your search
@@ -28,9 +28,7 @@ describe("Auth Controller - issueToken", function () {
|
||||
stub = sinon.stub(jwt, "sign").throws(error);
|
||||
const payload = { id: "123" };
|
||||
const appSettings = { jwtSecret: "my_secret" };
|
||||
expect(() => issueToken(payload, tokenType.ACCESS_TOKEN, appSettings)).to.throw(
|
||||
error
|
||||
);
|
||||
expect(() => issueToken(payload, tokenType.ACCESS_TOKEN, appSettings)).to.throw(error);
|
||||
});
|
||||
|
||||
it("should return a token if jwt.sign is successful and appSettings.jwtTTL is not defined", function () {
|
||||
@@ -163,9 +161,7 @@ describe("Auth Controller - registerUser", function () {
|
||||
req.db.checkSuperadmin.resolves(false);
|
||||
req.db.updateAppSettings.resolves();
|
||||
req.db.insertUser.resolves({ _id: "123" });
|
||||
req.settingsService.getSettings.rejects(
|
||||
new Error("settingsService.getSettings error")
|
||||
);
|
||||
req.settingsService.getSettings.rejects(new Error("settingsService.getSettings error"));
|
||||
await registerUser(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal("settingsService.getSettings error");
|
||||
@@ -304,9 +300,7 @@ describe("Auth Controller - loginUser", function () {
|
||||
user.comparePassword.resolves(false);
|
||||
await loginUser(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal(
|
||||
errorMessages.AUTH_INCORRECT_PASSWORD
|
||||
);
|
||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.AUTH_INCORRECT_PASSWORD);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -370,9 +364,7 @@ describe("Auth Controller - refreshAuthToken", function () {
|
||||
});
|
||||
|
||||
it("should reject if settingsService.getSettings fails", async function () {
|
||||
req.settingsService.getSettings.rejects(
|
||||
new Error("settingsService.getSettings error")
|
||||
);
|
||||
req.settingsService.getSettings.rejects(new Error("settingsService.getSettings error"));
|
||||
await refreshAuthToken(req, res, next);
|
||||
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
@@ -475,9 +467,7 @@ describe("Auth Controller - editUser", function () {
|
||||
await editUser(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].status).to.equal(401);
|
||||
expect(next.firstCall.args[0].message).to.equal(
|
||||
errorMessages.AUTH_INCORRECT_PASSWORD
|
||||
);
|
||||
expect(next.firstCall.args[0].message).to.equal(errorMessages.AUTH_INCORRECT_PASSWORD);
|
||||
});
|
||||
|
||||
it("should edit a user if it receives a proper request", async function () {
|
||||
@@ -863,8 +853,7 @@ describe("Auth Controller - deleteUser", function () {
|
||||
).to.be.true;
|
||||
expect(req.jobQueue.deleteJob.calledOnceWith(monitors[0])).to.be.true;
|
||||
expect(req.db.deleteChecks.calledOnceWith("monitor_id")).to.be.true;
|
||||
expect(req.db.deletePageSpeedChecksByMonitorId.calledOnceWith("monitor_id")).to.be
|
||||
.true;
|
||||
expect(req.db.deletePageSpeedChecksByMonitorId.calledOnceWith("monitor_id")).to.be.true;
|
||||
expect(req.db.deleteNotificationsByMonitorId.calledOnceWith("monitor_id")).to.be.true;
|
||||
expect(req.db.deleteTeam.calledOnceWith("team_id")).to.be.true;
|
||||
expect(req.db.deleteAllOtherUsers.calledOnce).to.be.true;
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import {
|
||||
createCheck,
|
||||
getChecks,
|
||||
getTeamChecks,
|
||||
deleteChecks,
|
||||
deleteChecksByTeamId,
|
||||
updateChecksTTL,
|
||||
} from "../../controllers/checkController.js";
|
||||
import { createCheck, getChecks, getTeamChecks, deleteChecks, deleteChecksByTeamId, updateChecksTTL } from "../../controllers/checkController.js";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { errorMessages, successMessages } from "../../utils/messages.js";
|
||||
import sinon from "sinon";
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import sinon from "sinon";
|
||||
|
||||
import {
|
||||
handleValidationError,
|
||||
handleError,
|
||||
fetchMonitorCertificate,
|
||||
} from "../../controllers/controllerUtils.js";
|
||||
import { handleValidationError, handleError, fetchMonitorCertificate } from "../../controllers/controllerUtils.js";
|
||||
import { expect } from "chai";
|
||||
import sslChecker from "ssl-checker";
|
||||
import { afterEach } from "node:test";
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
issueInvitation,
|
||||
inviteVerifyController,
|
||||
} from "../../controllers/inviteController.js";
|
||||
import { issueInvitation, inviteVerifyController } from "../../controllers/inviteController.js";
|
||||
import jwt from "jsonwebtoken";
|
||||
import sinon from "sinon";
|
||||
import joi from "joi";
|
||||
|
||||
@@ -623,9 +623,7 @@ describe("Monitor Controller - deleteMonitor", function () {
|
||||
req.jobQueue.deleteJob.rejects(error);
|
||||
await deleteMonitor(req, res, next);
|
||||
expect(logger.error.calledOnce).to.be.true;
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(
|
||||
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`
|
||||
);
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`);
|
||||
});
|
||||
|
||||
it("should log an error if deleteChecks throws an error", async function () {
|
||||
@@ -635,9 +633,7 @@ describe("Monitor Controller - deleteMonitor", function () {
|
||||
req.db.deleteChecks.rejects(error);
|
||||
await deleteMonitor(req, res, next);
|
||||
expect(logger.error.calledOnce).to.be.true;
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(
|
||||
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`
|
||||
);
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`);
|
||||
});
|
||||
|
||||
it("should log an error if deletePageSpeedChecksByMonitorId throws an error", async function () {
|
||||
@@ -647,9 +643,7 @@ describe("Monitor Controller - deleteMonitor", function () {
|
||||
req.db.deletePageSpeedChecksByMonitorId.rejects(error);
|
||||
await deleteMonitor(req, res, next);
|
||||
expect(logger.error.calledOnce).to.be.true;
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(
|
||||
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`
|
||||
);
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`);
|
||||
});
|
||||
|
||||
it("should log an error if deleteNotificationsByMonitorId throws an error", async function () {
|
||||
@@ -659,9 +653,7 @@ describe("Monitor Controller - deleteMonitor", function () {
|
||||
req.db.deleteNotificationsByMonitorId.rejects(error);
|
||||
await deleteMonitor(req, res, next);
|
||||
expect(logger.error.calledOnce).to.be.true;
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(
|
||||
`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`
|
||||
);
|
||||
expect(logger.error.firstCall.args[0].message).to.equal(`Error deleting associated records for monitor ${monitor._id} with name ${monitor.name}`);
|
||||
});
|
||||
|
||||
it("should return success message if all operations succeed", async function () {
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { afterEach } from "node:test";
|
||||
import {
|
||||
getMetrics,
|
||||
getJobs,
|
||||
addJob,
|
||||
obliterateQueue,
|
||||
} from "../../controllers/queueController.js";
|
||||
import { getMetrics, getJobs, addJob, obliterateQueue } from "../../controllers/queueController.js";
|
||||
import { successMessages } from "../../utils/messages.js";
|
||||
import sinon from "sinon";
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { afterEach } from "node:test";
|
||||
import {
|
||||
getAppSettings,
|
||||
updateAppSettings,
|
||||
} from "../../controllers/settingsController.js";
|
||||
import { getAppSettings, updateAppSettings } from "../../controllers/settingsController.js";
|
||||
|
||||
import { successMessages } from "../../utils/messages.js";
|
||||
import sinon from "sinon";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import sinon from "sinon";
|
||||
import {
|
||||
createStatusPage,
|
||||
getStatusPageByUrl,
|
||||
} from "../../controllers/statusPageController.js";
|
||||
import { createStatusPage, getStatusPageByUrl } from "../../controllers/statusPageController.js";
|
||||
|
||||
describe("statusPageController", function () {
|
||||
let req, res, next;
|
||||
|
||||
Reference in new issue
Block a user