Repository URL to install this package:
|
Version:
1.0.11 ▾
|
var Assert = require("assert");
describe("loop-ping", function(){
describe("good options", function(){
it("should not throw with mock logger", function(done){
Assert.doesNotThrow(function(){
var called = false;
require("../src/index.js")({
checkIntervalMs : 1,
logger : {
info : function(message){
if(!called) done();
called = true;
},
warn : function(message){
if(!called) done();
called = true;
}
}
});
});
});
it("should not throw with mock logger having extra interfaces", function(done){
Assert.doesNotThrow(function(){
var called = false;
require("../src/index.js")({
checkIntervalMs : 1,
logger : {
info : function(message){
if(!called) done();
called = true;
},
warn : function(message){
if(!called) done();
called = true;
},
error : function(message){
if(!called) done();
called = true;
}
}
});
});
});
});
describe("bad options", function(){
it("should throw when checkIntervalMs is non integer", function(){
Assert.throws(function(){
require("../src/index.js")({checkIntervalMs : "a"});
});
});
it("should throw when checkIntervalMs < 1", function(){
Assert.throws(function(){
require("../src/index.js")({checkIntervalMs : 0});
});
});
it("should throw when warnDelayMs is non integer", function(){
Assert.throws(function(){
require("../src/index.js")({warnDelayMs : "a"});
});
});
it("should throw when warnDelayMs < 1", function(){
Assert.throws(function(){
require("../src/index.js")({warnDelayMs : 0});
});
});
it("should throw when logger info func is not defined", function(){
Assert.throws(function(){
require("../src/index.js")({
logger : {
warn : function(message){
}
}
});
});
});
it("should throw when logger warn func is not defined", function(){
Assert.throws(function(){
require("../src/index.js")({
logger : {
info : function(message){
}
}
});
});
});
});
});