diff --git a/index.js b/index.js index 0957409..6f7ff8e 100644 --- a/index.js +++ b/index.js @@ -22,6 +22,13 @@ var utils = function() { } }; + return { + currentAddress: currentAddress + }; +}; + +var webApp = function() { + var healthCheckAction = function(customAction) { // provide the health check function which is used from nodejs health check endpoint // and add custom action to it @@ -66,7 +73,6 @@ var utils = function() { }; return { - currentAddress: currentAddress, registerHealthCheckEndpoint: registerHealthCheckEndpoint, registerNotificationEndpoint: registerNotificationEndpoint }; @@ -141,5 +147,6 @@ var master = function(masterUrl) { module.exports = { utils: utils, - master: master + master: master, + webApp: webApp }; diff --git a/test/index.js b/test/index.js index 2a7eb94..04c3d21 100644 --- a/test/index.js +++ b/test/index.js @@ -43,8 +43,12 @@ describe("utils", function(){ assert.equal(utils.currentAddress(), undefined); }); }); +}); + +describe("webApp", function(){ + var webApp = testee.webApp(); - describe("health check registration", function() { + describe("health check endpoint registration", function() { it("should add application endpoint /health", function() { // given var app = { @@ -53,7 +57,7 @@ describe("utils", function(){ var appSpy = sinon.spy(app, "get"); // when - utils.registerHealthCheckEndpoint(app); + webApp.registerHealthCheckEndpoint(app); // then assert(appSpy.withArgs("/health", sinon.match.func).calledOnce); @@ -71,7 +75,7 @@ describe("utils", function(){ }; // when - utils.registerHealthCheckEndpoint(app, customActionSpy); + webApp.registerHealthCheckEndpoint(app, customActionSpy); // then assert(customActionSpy.calledOnce); @@ -87,7 +91,7 @@ describe("utils", function(){ }; // when - utils.registerHealthCheckEndpoint(app, undefined); + webApp.registerHealthCheckEndpoint(app, undefined); // then // nothing to check, will fail if undefined would be executed @@ -103,7 +107,7 @@ describe("utils", function(){ var appSpy = sinon.spy(app, "post"); // when - utils.registerNotificationEndpoint(app); + webApp.registerNotificationEndpoint(app); // then assert(appSpy.withArgs("/notify", sinon.match.func).calledOnce); @@ -121,7 +125,7 @@ describe("utils", function(){ }; // when - utils.registerNotificationEndpoint(app, customActionSpy); + webApp.registerNotificationEndpoint(app, customActionSpy); // then assert(customActionSpy.calledOnce); @@ -137,7 +141,7 @@ describe("utils", function(){ }; // when - utils.registerNotificationEndpoint(app, undefined); + webApp.registerNotificationEndpoint(app, undefined); // then // nothing to check, will fail if undefined would be executed