From ed2f1a5d8d2144c6e95983a2a9f13c8437473b16 Mon Sep 17 00:00:00 2001 From: andsandv Date: Fri, 24 Oct 2014 15:29:30 +0200 Subject: [PATCH] Add healtcheck unit test --- unleash-server/test/routers.test.js | 37 +++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 unleash-server/test/routers.test.js diff --git a/unleash-server/test/routers.test.js b/unleash-server/test/routers.test.js new file mode 100644 index 0000000000..e4452e21a0 --- /dev/null +++ b/unleash-server/test/routers.test.js @@ -0,0 +1,37 @@ +var request = require('supertest'), + mockery = require('mockery'); + +describe('The routes', function () { + var server; + + before(function () { + mockery.enable({ + warnOnReplace: false, + warnOnUnregistered: false, + useCleanCache: true + }); + + mockery.registerSubstitute('./eventDb', '../test/eventDbMock'); + mockery.registerSubstitute('./featureDb', '../test/featureDbMock'); + + server = require('../server'); + request = request('http://localhost:' + server.app.get('port')); + }); + + after(function () { + mockery.disable(); + mockery.deregisterAll(); + server.server.close(); + }); + + describe('healthcheck', function () { + + it('returns health good', function (done) { + request.get('/health') + .expect('Content-Type', /json/) + .expect(200) + .expect('{"health":"GOOD"}', done); + }); + }); + +}); \ No newline at end of file