2014-11-25 14:41:11 +01:00
|
|
|
var request = require('supertest');
|
|
|
|
var mockery = require('mockery');
|
|
|
|
|
2014-12-03 15:22:03 +01:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
2014-11-25 14:41:11 +01:00
|
|
|
var server;
|
|
|
|
|
|
|
|
function setupMockServer() {
|
|
|
|
mockery.enable({
|
|
|
|
warnOnReplace: false,
|
|
|
|
warnOnUnregistered: false,
|
|
|
|
useCleanCache: true
|
|
|
|
});
|
|
|
|
|
|
|
|
mockery.registerSubstitute('./eventDb', '../test/eventDbMock');
|
|
|
|
mockery.registerSubstitute('./featureDb', '../test/featureDbMock');
|
|
|
|
mockery.registerSubstitute('./strategyDb', '../test/strategyDbMock');
|
|
|
|
|
2014-12-03 15:22:03 +01:00
|
|
|
var app = require('../app');
|
2014-11-25 14:41:11 +01:00
|
|
|
|
2014-12-03 15:22:03 +01:00
|
|
|
return request(app);
|
2014-11-25 14:41:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function tearDownMockServer() {
|
|
|
|
mockery.disable();
|
|
|
|
mockery.deregisterAll();
|
|
|
|
|
|
|
|
if (server) {
|
|
|
|
server.server.close();
|
|
|
|
server = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
setupMockServer: setupMockServer,
|
|
|
|
tearDownMockServer: tearDownMockServer
|
|
|
|
};
|