From 578751ef943f9f5f5c285da5c9f012996cf83680 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Tue, 18 Nov 2014 08:06:04 +0100 Subject: [PATCH] Fixed failing tests --- test/eventApi.test.js | 1 + test/eventStoreSpec.js | 1 + test/featureApiSpec.js | 1 + test/routers.test.js | 1 + test/strategyDbMock.js | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 41 insertions(+) create mode 100644 test/strategyDbMock.js diff --git a/test/eventApi.test.js b/test/eventApi.test.js index e51c76b986..8480c620ad 100644 --- a/test/eventApi.test.js +++ b/test/eventApi.test.js @@ -13,6 +13,7 @@ describe('The event api', function () { mockery.registerSubstitute('./eventDb', '../test/eventDbMock'); mockery.registerSubstitute('./featureDb', '../test/featureDbMock'); + mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock'); server = require('../server'); request = request('http://localhost:' + server.app.get('port')); diff --git a/test/eventStoreSpec.js b/test/eventStoreSpec.js index 9f711747a1..7405581a0c 100644 --- a/test/eventStoreSpec.js +++ b/test/eventStoreSpec.js @@ -13,6 +13,7 @@ describe('EventStore', function () { }); mockery.registerSubstitute('./eventDb', '../test/eventDbMock'); + mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock'); eventStore = require('../lib/eventStore'); }); diff --git a/test/featureApiSpec.js b/test/featureApiSpec.js index 93467af68d..52ac7e8eab 100644 --- a/test/featureApiSpec.js +++ b/test/featureApiSpec.js @@ -13,6 +13,7 @@ describe('The api', function () { mockery.registerSubstitute('./eventDb', '../test/eventDbMock'); mockery.registerSubstitute('./featureDb', '../test/featureDbMock'); + mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock'); server = require('../server'); request = request('http://localhost:' + server.app.get('port')); diff --git a/test/routers.test.js b/test/routers.test.js index e4452e21a0..7345bf639b 100644 --- a/test/routers.test.js +++ b/test/routers.test.js @@ -13,6 +13,7 @@ describe('The routes', function () { mockery.registerSubstitute('./eventDb', '../test/eventDbMock'); mockery.registerSubstitute('./featureDb', '../test/featureDbMock'); + mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock'); server = require('../server'); request = request('http://localhost:' + server.app.get('port')); diff --git a/test/strategyDbMock.js b/test/strategyDbMock.js new file mode 100644 index 0000000000..e518d51c08 --- /dev/null +++ b/test/strategyDbMock.js @@ -0,0 +1,37 @@ +var Promise = require("bluebird"); + +var strategies = [ + { + name: "default", + description: "Default on or off Strategy." + }, + { + name: "usersWithEmail", + description: "Active for users defined in the comma-separated emails-parameter.", + parametersTemplate: { + emails: "String" + } + } +]; + +function byName(name) { + return strategies.filter(function(s) { + return s.name === name; + })[0]; +} + +module.exports = { + getStrategies: function() { + return new Promise(function (resolve) { + resolve(strategies); + }); + }, + getFeature: function(name) { + var feature = byName(name); + if(feature) { + return Promise.resolve(feature); + } else { + return Promise.reject("strategy not found"); + } + } +}; \ No newline at end of file