Add missing test case for docker monitor type
This commit is contained in:
1 parent
c4d26556c7
commit
88ae686116
1 file changed
+36
@@ -891,6 +891,18 @@ describe("monitorModule", () => {
|
|||||||
url: "https://test.com",
|
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 = [
|
const checkDocs = [
|
||||||
{
|
{
|
||||||
@@ -1004,6 +1016,30 @@ describe("monitorModule", () => {
|
|||||||
expect(result.periodUptime).to.be.a("number");
|
expect(result.periodUptime).to.be.a("number");
|
||||||
expect(result.aggregateData).to.be.an("array");
|
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 () => {
|
it("should return monitor stats with calculated values", async () => {
|
||||||
req.query.sortOrder = "asc";
|
req.query.sortOrder = "asc";
|
||||||
const result = await getMonitorStatsById(req);
|
const result = await getMonitorStatsById(req);
|
||||||
|
|||||||
Reference in new issue
Block a user