fixed error in handlePing test
This commit is contained in:
1 parent
2fcdb20883
commit
1c2d758e17
1 file changed
+15
-22
@@ -308,43 +308,36 @@ describe("networkService - handlePing", () => {
|
|||||||
sinon.restore();
|
sinon.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle a successful ping response", async function () {
|
it("should handle a successful ping response", async () => {
|
||||||
const response = { alive: true };
|
const response = { alive: true };
|
||||||
const responseTime = 0;
|
const responseTime = 0;
|
||||||
pingMock.promise.probe.resolves(response);
|
pingMock.promise.probe.returns(response);
|
||||||
logAndStoreCheckStub.resolves();
|
logAndStoreCheckStub.resolves();
|
||||||
await networkService.handlePing(job);
|
await networkService.handlePing(job);
|
||||||
expect(
|
expect(
|
||||||
logAndStoreCheckStub.calledOnceWith(
|
logAndStoreCheckStub.calledOnceWith({
|
||||||
{
|
monitorId: job.data._id,
|
||||||
monitorId: job.data._id,
|
status: response.alive,
|
||||||
status: true,
|
responseTime,
|
||||||
responseTime,
|
message: successMessages.PING_SUCCESS,
|
||||||
message: successMessages.PING_SUCCESS,
|
})
|
||||||
},
|
|
||||||
networkService.db.createCheck
|
|
||||||
)
|
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(handleStatusUpdateStub.calledOnceWith(job, true)).to.be.true;
|
expect(handleStatusUpdateStub.calledOnceWith(job, true)).to.be.true;
|
||||||
});
|
});
|
||||||
it("should handle a successful ping response and isAlive === false", async function () {
|
it("should handle a successful response and isAlive === false", async function () {
|
||||||
const response = { alive: false };
|
const response = { alive: false };
|
||||||
const responseTime = 0;
|
const responseTime = 0;
|
||||||
pingMock.promise.probe.resolves(response);
|
pingMock.promise.probe.resolves(response);
|
||||||
logAndStoreCheckStub.resolves();
|
logAndStoreCheckStub.resolves();
|
||||||
|
|
||||||
await networkService.handlePing(job);
|
await networkService.handlePing(job);
|
||||||
console.log(logAndStoreCheckStub.getCall(0).args[0]);
|
|
||||||
expect(
|
expect(
|
||||||
logAndStoreCheckStub.calledOnceWith(
|
logAndStoreCheckStub.calledOnceWith({
|
||||||
{
|
monitorId: job.data._id,
|
||||||
monitorId: job.data._id,
|
status: false,
|
||||||
status: false,
|
responseTime,
|
||||||
responseTime,
|
message: errorMessages.PING_CANNOT_RESOLVE,
|
||||||
message: errorMessages.PING_CANNOT_RESOLVE,
|
})
|
||||||
},
|
|
||||||
networkService.db.createCheck
|
|
||||||
)
|
|
||||||
).to.be.true;
|
).to.be.true;
|
||||||
expect(handleStatusUpdateStub.calledOnceWith(job, false)).to.be.true;
|
expect(handleStatusUpdateStub.calledOnceWith(job, false)).to.be.true;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user