mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-04-25 10:28:29 -05:00
Add missing tests for 100% coverage
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
module.exports = {
|
||||
require: ["chai/register-expect.js"], // Include Chai's "expect" interface globally
|
||||
// spec: "tests/**/*.test.js", // Specify test files
|
||||
spec: "tests/**/*.test.js", // Specify test files
|
||||
timeout: 5000, // Set test-case timeout in milliseconds
|
||||
recursive: true, // Include subdirectories
|
||||
reporter: "spec", // Use the "spec" reporter
|
||||
|
||||
@@ -31,6 +31,7 @@ const createCheck = async (req, res, next) => {
|
||||
.status(200)
|
||||
.json({ success: true, msg: successMessages.CHECK_CREATE, data: check });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
next(handleError(error, SERVICE_NAME, "createCheck"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,7 +43,25 @@ describe("Check Controller - createCheck", () => {
|
||||
};
|
||||
await createCheck(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].status).to.equal(422);
|
||||
});
|
||||
|
||||
it("should call next with error if data retrieval fails", async () => {
|
||||
req.params = {
|
||||
monitorId: "monitorId",
|
||||
};
|
||||
req.body = {
|
||||
monitorId: "monitorId",
|
||||
status: true,
|
||||
responseTime: 100,
|
||||
statusCode: 200,
|
||||
message: "message",
|
||||
};
|
||||
req.db.createCheck.rejects(new Error("error"));
|
||||
await createCheck(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
});
|
||||
|
||||
it("should return a success message if check is created", async () => {
|
||||
req.params = {
|
||||
monitorId: "monitorId",
|
||||
@@ -115,12 +133,12 @@ describe("Check Controller - getChecks", () => {
|
||||
});
|
||||
|
||||
it("should call next with error if data retrieval fails", async () => {
|
||||
req.params = {
|
||||
monitorId: "monitorId",
|
||||
};
|
||||
req.db.getChecks.rejects(new Error("error"));
|
||||
await getChecks(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
req.db.getChecks.resolves([]);
|
||||
req.db.getChecksCount.rejects(new Error("error"));
|
||||
await getChecks(req, res, next);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user