From ff6051b6b0a7e28237d04bc892447857e9c16029 Mon Sep 17 00:00:00 2001 From: om-3004 Date: Thu, 17 Oct 2024 16:59:49 +0530 Subject: [PATCH] Update test case for url resolution to make it more specific --- Server/controllers/monitorController.js | 2 +- Server/tests/controllers/monitorController.test.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Server/controllers/monitorController.js b/Server/controllers/monitorController.js index c56e8851b..302e0ff11 100644 --- a/Server/controllers/monitorController.js +++ b/Server/controllers/monitorController.js @@ -264,7 +264,7 @@ const createMonitor = async (req, res, next) => { }; /** - * Checks if the endpoint can be resolved and adds it to the job queue. + * Checks if the endpoint can be resolved * @async * @param {Object} req - The Express request object. * @property {Object} req.query - The query parameters of the request. diff --git a/Server/tests/controllers/monitorController.test.js b/Server/tests/controllers/monitorController.test.js index bd89b3dea..0a9dbafe6 100644 --- a/Server/tests/controllers/monitorController.test.js +++ b/Server/tests/controllers/monitorController.test.js @@ -490,6 +490,7 @@ describe("Monitor Controllor - checkEndpointResolution", () => { expect(errorPassedToNext).to.be.an.instanceOf(Error); expect(errorPassedToNext.message).to.include('DNS resolution failed'); expect(errorPassedToNext.code).to.equal('ENOTFOUND'); + expect(errorPassedToNext.status).to.equal(500); }); it('should reject with an error if query validation fails', async () => { req.query.monitorURL = 'invalid-url'; @@ -498,6 +499,7 @@ describe("Monitor Controllor - checkEndpointResolution", () => { const error = next.getCall(0).args[0]; expect(next.firstCall.args[0]).to.be.an("error"); expect(next.firstCall.args[0].status).to.equal(422); + expect(error.message).to.equal('"monitorURL" must be a valid uri'); }); });