Skip to content

Commit

Permalink
Merge pull request #1158 from bluewave-labs/fix/be/tests-docker-test
Browse files Browse the repository at this point in the history
Add missing test case for docker monitor type
  • Loading branch information
ajhollid authored Nov 15, 2024
2 parents c4d2655 + 88ae686 commit 0b7c536
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Server/tests/db/monitorModule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,18 @@ describe("monitorModule", () => {
url: "https://test.com",
}),
};
const mockMonitorDocker = {
_id: "monitor123",
type: "docker",
name: "Test Monitor",
url: "https://test.com",
toObject: () => ({
_id: "monitor123",
type: "http",
name: "Test Monitor",
url: "https://test.com",
}),
};

const checkDocs = [
{
Expand Down Expand Up @@ -1004,6 +1016,30 @@ describe("monitorModule", () => {
expect(result.periodUptime).to.be.a("number");
expect(result.aggregateData).to.be.an("array");
});
it("should return monitor stats with calculated values, docker type", async () => {
monitorFindByIdStub.returns(mockMonitorDocker);
req.query.sortOrder = "desc";
const result = await getMonitorStatsById(req);
expect(result).to.include.keys([
"_id",
"type",
"name",
"url",
"uptimeDuration",
"lastChecked",
"latestResponseTime",
"periodIncidents",
"periodTotalChecks",
"periodAvgResponseTime",
"periodUptime",
"aggregateData",
]);
expect(result.latestResponseTime).to.equal(100);
expect(result.periodTotalChecks).to.equal(3);
expect(result.periodIncidents).to.equal(1);
expect(result.periodUptime).to.be.a("number");
expect(result.aggregateData).to.be.an("array");
});
it("should return monitor stats with calculated values", async () => {
req.query.sortOrder = "asc";
const result = await getMonitorStatsById(req);
Expand Down

0 comments on commit 0b7c536

Please sign in to comment.