mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Move away from __defineGetter syntax, in red and server
Bump test coverage forwards a bit
This commit is contained in:
parent
3cbc1bbb1b
commit
234abd82a2
26
red/red.js
26
red/red.js
@ -24,15 +24,12 @@ var fs = require("fs");
|
||||
var settings = require("./settings");
|
||||
var credentials = require("./nodes/credentials");
|
||||
var auth = require("./api/auth");
|
||||
|
||||
var path = require('path');
|
||||
var events = require("events");
|
||||
|
||||
process.env.NODE_RED_HOME = process.env.NODE_RED_HOME || path.resolve(__dirname+"/..");
|
||||
|
||||
var events = require("events");
|
||||
|
||||
var RED = {
|
||||
|
||||
init: function(httpServer,userSettings) {
|
||||
userSettings.version = this.version();
|
||||
log.init(userSettings);
|
||||
@ -40,7 +37,6 @@ var RED = {
|
||||
server.init(httpServer,settings);
|
||||
return server.app;
|
||||
},
|
||||
|
||||
start: server.start,
|
||||
stop: server.stop,
|
||||
nodes: nodes,
|
||||
@ -55,18 +51,16 @@ var RED = {
|
||||
needsPermission: auth.needsPermission
|
||||
},
|
||||
version: function () {
|
||||
var p = require(path.join(process.env.NODE_RED_HOME,"package.json"));
|
||||
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
|
||||
/* istanbul ignore else */
|
||||
if (fs.existsSync(path.join(process.env.NODE_RED_HOME,".git"))) {
|
||||
return p.version+".git";
|
||||
} else {
|
||||
return p.version;
|
||||
}
|
||||
p += ".git";
|
||||
}
|
||||
return p;
|
||||
},
|
||||
get app() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app },
|
||||
get httpAdmin() { return server.app },
|
||||
get httpNode() { return server.nodeApp },
|
||||
get server() { return server.server }
|
||||
};
|
||||
|
||||
RED.__defineGetter__("app", function() { console.log("Deprecated use of RED.app - use RED.httpAdmin instead"); return server.app });
|
||||
RED.__defineGetter__("httpAdmin", function() { return server.app });
|
||||
RED.__defineGetter__("httpNode", function() { return server.nodeApp });
|
||||
RED.__defineGetter__("server", function() { return server.server });
|
||||
|
||||
module.exports = RED;
|
||||
|
@ -242,8 +242,6 @@ function reportMetrics() {
|
||||
log.log(metrics);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function stop() {
|
||||
if (runtimeMetricInterval) {
|
||||
clearInterval(runtimeMetricInterval);
|
||||
@ -261,9 +259,9 @@ module.exports = {
|
||||
reportAddedModules: reportAddedModules,
|
||||
reportRemovedModules: reportRemovedModules,
|
||||
installModule: installModule,
|
||||
uninstallModule: uninstallModule
|
||||
}
|
||||
uninstallModule: uninstallModule,
|
||||
|
||||
module.exports.__defineGetter__("app", function() { return app });
|
||||
module.exports.__defineGetter__("nodeApp", function() { return nodeApp });
|
||||
module.exports.__defineGetter__("server", function() { return server });
|
||||
get app() { return app },
|
||||
get nodeApp() { return nodeApp },
|
||||
get server() { return server }
|
||||
}
|
||||
|
@ -17,6 +17,30 @@ var should = require("should");
|
||||
|
||||
describe("red/red", function() {
|
||||
it('can be required without errors', function() {
|
||||
require("../../red/red");
|
||||
var RED = require("../../red/red");
|
||||
});
|
||||
|
||||
var RED = require("../../red/red");
|
||||
|
||||
it('returns an app object', function() {
|
||||
var srv = RED.app.use("/test", function() { return "app"; });
|
||||
srv.should.be.an.instanceOf(Object);
|
||||
});
|
||||
|
||||
it('returns an httpAdmin object', function() {
|
||||
var srv = RED.httpAdmin.use("/test", function() { return "Admin"; });
|
||||
srv.should.be.an.instanceOf(Object);
|
||||
});
|
||||
|
||||
it('reuturns an httpNode object', function() {
|
||||
var srv = RED.httpNode.use("/test", function() { return "Node"; });
|
||||
srv.should.be.an.instanceOf(Object);
|
||||
});
|
||||
|
||||
it('it returns a server object', function() {
|
||||
var srv = RED.server;
|
||||
srv.should.be.an.instanceOf(Object).and.have.property('domain', null);
|
||||
srv.should.be.an.instanceOf(Object).and.have.property('timeout', 120000);
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user