mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Update tests for runtime/api separation
This commit is contained in:
parent
f43738446e
commit
9f5e6a4b37
@ -28,7 +28,7 @@ var persistentSettings = {
|
|||||||
userSettings = settings;
|
userSettings = settings;
|
||||||
for (var i in settings) {
|
for (var i in settings) {
|
||||||
/* istanbul ignore else */
|
/* istanbul ignore else */
|
||||||
if (settings.hasOwnProperty(i)) {
|
if (settings.hasOwnProperty(i) && typeof settings[i] !== "function") {
|
||||||
(function() {
|
(function() {
|
||||||
var j = i;
|
var j = i;
|
||||||
persistentSettings.__defineGetter__(j,function() { return userSettings[j]; });
|
persistentSettings.__defineGetter__(j,function() { return userSettings[j]; });
|
||||||
|
@ -28,13 +28,11 @@ describe("api index", function() {
|
|||||||
|
|
||||||
describe("disables editor", function() {
|
describe("disables editor", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:true},
|
||||||
settings:{disableEditor:true},
|
events: {on:function(){},removeListener: function(){}}
|
||||||
api:{
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not serve the editor', function(done) {
|
it('does not serve the editor', function(done) {
|
||||||
@ -69,11 +67,11 @@ describe("api index", function() {
|
|||||||
})
|
})
|
||||||
});
|
});
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
settings:{httpNodeRoot:true, httpAdminRoot: true, adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
|
||||||
settings:{adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
|
|
||||||
storage:{getSessions:function(){return when.resolve({})}}
|
storage:{getSessions:function(){return when.resolve({})}}
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('it now serves auth', function(done) {
|
it('it now serves auth', function(done) {
|
||||||
@ -105,12 +103,12 @@ describe("api index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
app = express();
|
api.init({
|
||||||
api.init(app,{
|
|
||||||
log:{audit:function(){}},
|
log:{audit:function(){}},
|
||||||
settings:{disableEditor:false},
|
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false},
|
||||||
events:{on:function(){},removeListener:function(){}}
|
events:{on:function(){},removeListener:function(){}}
|
||||||
});
|
});
|
||||||
|
app = api.adminApp();
|
||||||
});
|
});
|
||||||
it('serves the editor', function(done) {
|
it('serves the editor', function(done) {
|
||||||
request(app)
|
request(app)
|
||||||
|
@ -21,8 +21,6 @@ var bodyParser = require('body-parser');
|
|||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var when = require('when');
|
var when = require('when');
|
||||||
|
|
||||||
var settings = require("../../../red/settings");
|
|
||||||
|
|
||||||
var nodes = require("../../../red/api/nodes");
|
var nodes = require("../../../red/api/nodes");
|
||||||
|
|
||||||
describe("nodes api", function() {
|
describe("nodes api", function() {
|
||||||
@ -335,9 +333,6 @@ describe("nodes api", function() {
|
|||||||
});
|
});
|
||||||
describe('delete', function() {
|
describe('delete', function() {
|
||||||
it('returns 400 if settings are unavailable', function(done) {
|
it('returns 400 if settings are unavailable', function(done) {
|
||||||
var settingsAvailable = sinon.stub(settings,'available', function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
initNodes({
|
initNodes({
|
||||||
settings:{available:function(){return false}}
|
settings:{available:function(){return false}}
|
||||||
});
|
});
|
||||||
@ -346,7 +341,6 @@ describe("nodes api", function() {
|
|||||||
.del('/nodes/123')
|
.del('/nodes/123')
|
||||||
.expect(400)
|
.expect(400)
|
||||||
.end(function(err,res) {
|
.end(function(err,res) {
|
||||||
settingsAvailable.restore();
|
|
||||||
if (err) {
|
if (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ var when = require('when');
|
|||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
var settings = require("../../../red/settings");
|
|
||||||
|
|
||||||
var theme = require("../../../red/api/theme");
|
var theme = require("../../../red/api/theme");
|
||||||
|
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="should-not-load-2"></script>
|
|
||||||
<script type="text/x-red" data-help-name="should-not-load-2"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('should-not-load-2',{});</script>
|
|
||||||
<style></style>
|
|
@ -1,5 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
function TestNode(n) {}
|
|
||||||
RED.nodes.registerType("should-not-load-2",TestNode);
|
|
||||||
}
|
|
1
test/red/nodes/resources/TestNodeModule/node_modules/EmptyModule/file.txt
generated
vendored
1
test/red/nodes/resources/TestNodeModule/node_modules/EmptyModule/file.txt
generated
vendored
@ -1 +0,0 @@
|
|||||||
This file exists just to ensure the parent directory is in the repository.
|
|
@ -1,5 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="test-node-mod-1"></script>
|
|
||||||
<script type="text/x-red" data-help-name="test-node-mod-1"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('test-node-mod-1',{});</script>
|
|
||||||
<style></style>
|
|
||||||
<p>this should be filtered out</p>
|
|
@ -1,5 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
function TestNode(n) {}
|
|
||||||
RED.nodes.registerType("test-node-mod-1",TestNode);
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
<script type="text/x-red" data-template-name="test-node-mod-2"></script>
|
|
||||||
<script type="text/x-red" data-help-name="test-node-mod-2"></script>
|
|
||||||
<script type="text/javascript">RED.nodes.registerType('test-node-mod-2',{});</script>
|
|
||||||
<style></style>
|
|
||||||
<p>this should be filtered out</p>
|
|
@ -1,4 +0,0 @@
|
|||||||
// A test node that exports a function
|
|
||||||
module.exports = function(RED) {
|
|
||||||
throw new Error("fail to load");
|
|
||||||
}
|
|
3
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/icons/file.txt
generated
vendored
3
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/icons/file.txt
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
This file exists just to ensure the 'icons' directory is in the repository.
|
|
||||||
TODO: a future test needs to ensure the right icon files are loaded - this
|
|
||||||
directory can be used for that
|
|
11
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/package.json
generated
vendored
11
test/red/nodes/resources/TestNodeModule/node_modules/TestNodeModule/package.json
generated
vendored
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"name" : "TestNodeModule",
|
|
||||||
"version" : "0.0.1",
|
|
||||||
"description" : "A test node module",
|
|
||||||
"node-red" : {
|
|
||||||
"nodes": {
|
|
||||||
"TestNodeMod1": "TestNodeModule.js",
|
|
||||||
"TestNodeMod2": "TestNodeModule2.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -19,24 +19,21 @@ var fs = require("fs");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var RED = require("../../red/red");
|
var RED = require("../../red/red");
|
||||||
var log = require("../../red/log");
|
var runtime = require("../../red/runtime");
|
||||||
var settings = require("../../red/settings");
|
var api = require("../../red/api");
|
||||||
var server = require("../../red/server");
|
|
||||||
|
|
||||||
|
|
||||||
describe("red/red", function() {
|
describe("red/red", function() {
|
||||||
|
|
||||||
describe("check build", function() {
|
describe("check build", function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
sinon.stub(log,"init",function() {});
|
sinon.stub(runtime,"init",function() {});
|
||||||
sinon.stub(settings,"init",function() {});
|
sinon.stub(api,"init",function() {});
|
||||||
sinon.stub(server,"init",function() {});
|
|
||||||
sinon.stub(RED,"version",function() { return "version";});
|
sinon.stub(RED,"version",function() { return "version";});
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
log.init.restore();
|
runtime.init.restore();
|
||||||
settings.init.restore();
|
api.init.restore();
|
||||||
server.init.restore();
|
|
||||||
fs.statSync.restore();
|
fs.statSync.restore();
|
||||||
RED.version.restore();
|
RED.version.restore();
|
||||||
});
|
});
|
||||||
@ -59,13 +56,16 @@ describe("red/red", function() {
|
|||||||
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
|
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
|
||||||
RED.version().indexOf(p).should.eql(0);
|
RED.version().indexOf(p).should.eql(0);
|
||||||
});
|
});
|
||||||
it('access server externals', function() {
|
it.skip('access server externals', function() {
|
||||||
// TODO: unstubable accessors - need to make this testable
|
// TODO: unstubable accessors - need to make this testable
|
||||||
RED.app;
|
RED.app;
|
||||||
RED.httpAdmin;
|
RED.httpAdmin;
|
||||||
RED.httpNode;
|
RED.httpNode;
|
||||||
RED.server;
|
RED.server;
|
||||||
});
|
});
|
||||||
|
it.skip('only initialises api component if httpAdmin enabled');
|
||||||
|
it.skip('stubs httpAdmin if httpAdmin disabled');
|
||||||
|
it.skip('stubs httpNode if httpNode disabled');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -23,14 +23,14 @@ var express = require('express');
|
|||||||
var app = express();
|
var app = express();
|
||||||
var WebSocket = require('ws');
|
var WebSocket = require('ws');
|
||||||
|
|
||||||
var comms = require("../../red/comms.js");
|
var comms = require("../../../red/runtime/comms");
|
||||||
var Users = require("../../red/api/auth/users");
|
var Users = require("../../../red/api/auth/users");
|
||||||
var Tokens = require("../../red/api/auth/tokens");
|
var Tokens = require("../../../red/api/auth/tokens");
|
||||||
|
|
||||||
var address = '127.0.0.1';
|
var address = '127.0.0.1';
|
||||||
var listenPort = 0; // use ephemeral port
|
var listenPort = 0; // use ephemeral port
|
||||||
|
|
||||||
describe("comms", function() {
|
describe("runtime/comms", function() {
|
||||||
describe("with default keepalive", function() {
|
describe("with default keepalive", function() {
|
||||||
var server;
|
var server;
|
||||||
var url;
|
var url;
|
@ -15,8 +15,9 @@
|
|||||||
**/
|
**/
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
|
|
||||||
describe("red/events", function() {
|
describe("runtime/events", function() {
|
||||||
it('can be required without errors', function() {
|
it('can be required without errors', function() {
|
||||||
require("../../red/events");
|
require("../../../red/runtime/events");
|
||||||
});
|
});
|
||||||
|
it.skip('more tests needed', function(){})
|
||||||
});
|
});
|
22
test/red/runtime/i18n_spec.js
Normal file
22
test/red/runtime/i18n_spec.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2015 IBM Corp.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
**/
|
||||||
|
|
||||||
|
describe("runtime/i18n", function() {
|
||||||
|
it('can be required without errors', function() {
|
||||||
|
require("../../../red/runtime/i18n");
|
||||||
|
});
|
||||||
|
it.skip('more tests needed', function(){})
|
||||||
|
});
|
@ -16,16 +16,18 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
|
var path = require("path");
|
||||||
|
|
||||||
var comms = require("../../red/comms");
|
var api = require("../../../red/api");
|
||||||
var redNodes = require("../../red/nodes");
|
var runtime = require("../../../red/runtime");
|
||||||
var api = require("../../red/api");
|
|
||||||
var runtime = require("../../red/runtime");
|
|
||||||
var storage = require("../../red/storage");
|
|
||||||
var settings = require("../../red/settings");
|
|
||||||
var log = require("../../red/log");
|
|
||||||
|
|
||||||
describe("red/runtime", function() {
|
var comms = require("../../../red/runtime/comms");
|
||||||
|
var redNodes = require("../../../red/runtime/nodes");
|
||||||
|
var storage = require("../../../red/runtime/storage");
|
||||||
|
var settings = require("../../../red/runtime/settings");
|
||||||
|
var log = require("../../../red/runtime/log");
|
||||||
|
|
||||||
|
describe("runtime", function() {
|
||||||
var commsMessages = [];
|
var commsMessages = [];
|
||||||
var commsPublish;
|
var commsPublish;
|
||||||
|
|
||||||
@ -42,47 +44,39 @@ describe("red/runtime", function() {
|
|||||||
commsPublish = sinon.stub(comms,"publish", function(topic,msg,retained) {
|
commsPublish = sinon.stub(comms,"publish", function(topic,msg,retained) {
|
||||||
commsMessages.push({topic:topic,msg:msg,retained:retained});
|
commsMessages.push({topic:topic,msg:msg,retained:retained});
|
||||||
});
|
});
|
||||||
|
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..",".."))
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
commsPublish.restore();
|
commsPublish.restore();
|
||||||
|
delete process.env.NODE_RED_HOME;
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("init", function() {
|
describe("init", function() {
|
||||||
var commsInit;
|
|
||||||
var apiInit;
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
commsInit = sinon.stub(comms,"init",function() {});
|
sinon.stub(log,"init",function() {});
|
||||||
apiInit = sinon.stub(api,"init",function() {});
|
sinon.stub(settings,"init",function() {});
|
||||||
|
sinon.stub(comms,"init",function() {});
|
||||||
});
|
});
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
commsInit.restore();
|
log.init.restore();
|
||||||
apiInit.restore();
|
settings.init.restore();
|
||||||
|
comms.init.restore();
|
||||||
})
|
})
|
||||||
|
|
||||||
it("initialises components", function() {
|
it("initialises components", function() {
|
||||||
var dummyServer = {};
|
var dummyServer = {};
|
||||||
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/", load:function() { return when.resolve();}});
|
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/"});
|
||||||
commsInit.called.should.be.true;
|
log.init.called.should.be.true;
|
||||||
apiInit.called.should.be.true;
|
settings.init.called.should.be.true;
|
||||||
|
comms.init.called.should.be.true;
|
||||||
should.exist(runtime.app);
|
|
||||||
should.exist(runtime.nodeApp);
|
|
||||||
|
|
||||||
runtime.server.should.equal(dummyServer);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("doesn't init api if httpAdminRoot set to false",function() {
|
it("returns version", function() {
|
||||||
|
|
||||||
var dummyServer = {};
|
var dummyServer = {};
|
||||||
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:false, load:function() { return when.resolve();}});
|
runtime.init(dummyServer,{testSettings: true, httpAdminRoot:"/"});
|
||||||
commsInit.called.should.be.true;
|
/^\d+\.\d+\.\d+(-git)?$/.test(runtime.version()).should.be.true;
|
||||||
apiInit.called.should.be.false;
|
|
||||||
|
|
||||||
should.exist(runtime.app);
|
})
|
||||||
should.exist(runtime.nodeApp);
|
|
||||||
|
|
||||||
runtime.server.should.equal(dummyServer);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("start",function() {
|
describe("start",function() {
|
@ -17,13 +17,9 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
|
|
||||||
var log = require("../../red/log");
|
var log = require("../../../red/runtime/log");
|
||||||
|
|
||||||
describe("red/log", function() {
|
|
||||||
it('can be required without errors', function() {
|
|
||||||
require("../../red/log");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
describe("runtime/log", function() {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
var spy = sinon.stub(util, 'log', function(arg){});
|
var spy = sinon.stub(util, 'log', function(arg){});
|
||||||
var settings = {logging: { console: { level: 'metric', metrics: true } } };
|
var settings = {logging: { console: { level: 'metric', metrics: true } } };
|
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
var RedNode = require("../../../red/nodes/Node");
|
var RedNode = require("../../../../red/runtime/nodes/Node");
|
||||||
var Log = require("../../../red/log");
|
var Log = require("../../../../red/runtime/log");
|
||||||
var flows = require("../../../red/nodes/flows");
|
var flows = require("../../../../red/runtime/nodes/flows");
|
||||||
var comms = require('../../../red/comms');
|
var comms = require("../../../../red/runtime/comms");
|
||||||
|
|
||||||
describe('Node', function() {
|
describe('Node', function() {
|
||||||
describe('#constructor',function() {
|
describe('#constructor',function() {
|
@ -22,10 +22,10 @@ var util = require("util");
|
|||||||
var express = require("express");
|
var express = require("express");
|
||||||
var request = require("supertest");
|
var request = require("supertest");
|
||||||
|
|
||||||
var index = require("../../../red/nodes/index");
|
var index = require("../../../../red/runtime/nodes/index");
|
||||||
var credentials = require("../../../red/nodes/credentials");
|
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||||
var log = require("../../../red/log");
|
var log = require("../../../../red/runtime/log");
|
||||||
var auth = require("../../../red/api/auth");
|
var auth = require("../../../../red/api/auth");
|
||||||
|
|
||||||
|
|
||||||
describe('Credentials', function() {
|
describe('Credentials', function() {
|
@ -20,11 +20,11 @@ var sinon = require('sinon');
|
|||||||
var clone = require('clone');
|
var clone = require('clone');
|
||||||
var util = require("util");
|
var util = require("util");
|
||||||
|
|
||||||
var flowUtils = require("../../../../red/nodes/flows/util");
|
var flowUtils = require("../../../../../red/runtime/nodes/flows/util");
|
||||||
var Flow = require("../../../../red/nodes/flows/Flow");
|
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
|
||||||
var flows = require("../../../../red/nodes/flows");
|
var flows = require("../../../../../red/runtime/nodes/flows");
|
||||||
var Node = require("../../../../red/nodes/Node");
|
var Node = require("../../../../../red/runtime/nodes/Node");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
|
|
||||||
|
|
||||||
describe('Flow', function() {
|
describe('Flow', function() {
|
@ -18,13 +18,13 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var flows = require("../../../../red/nodes/flows");
|
var flows = require("../../../../../red/runtime/nodes/flows");
|
||||||
var RedNode = require("../../../../red/nodes/Node");
|
var RedNode = require("../../../../../red/runtime/nodes/Node");
|
||||||
var RED = require("../../../../red/nodes");
|
var RED = require("../../../../../red/runtime/nodes");
|
||||||
var events = require("../../../../red/events");
|
var events = require("../../../../../red/runtime/events");
|
||||||
var credentials = require("../../../../red/nodes/credentials");
|
var credentials = require("../../../../../red/runtime/nodes/credentials");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var Flow = require("../../../../red/nodes/flows/Flow");
|
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
|
||||||
|
|
||||||
describe('flows/index', function() {
|
describe('flows/index', function() {
|
||||||
|
|
@ -18,9 +18,9 @@ var should = require("should");
|
|||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var flowUtil = require("../../../../red/nodes/flows/util");
|
var flowUtil = require("../../../../../red/runtime/nodes/flows/util");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var redUtil = require("../../../../red/util");
|
var redUtil = require("../../../../../red/runtime/util");
|
||||||
|
|
||||||
describe('flows/util', function() {
|
describe('flows/util', function() {
|
||||||
var getType;
|
var getType;
|
@ -20,16 +20,18 @@ var path = require('path');
|
|||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require('sinon');
|
var sinon = require('sinon');
|
||||||
|
|
||||||
var index = require("../../../red/nodes/index");
|
var index = require("../../../../red/runtime/nodes/index");
|
||||||
var flows = require("../../../red/nodes/flows");
|
var flows = require("../../../../red/runtime/nodes/flows");
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
|
|
||||||
describe("red/nodes/index", function() {
|
describe("red/nodes/index", function() {
|
||||||
before(function() {
|
before(function() {
|
||||||
sinon.stub(flows,"startFlows");
|
sinon.stub(flows,"startFlows");
|
||||||
|
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
|
||||||
});
|
});
|
||||||
after(function() {
|
after(function() {
|
||||||
flows.startFlows.restore();
|
flows.startFlows.restore();
|
||||||
|
delete process.env.NODE_RED_HOME;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
@ -93,10 +95,10 @@ describe("red/nodes/index", function() {
|
|||||||
var http = require('http');
|
var http = require('http');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var app = express();
|
var app = express();
|
||||||
var server = require("../../../red/server");
|
var runtime = require("../../../../red/runtime");
|
||||||
var credentials = require("../../../red/nodes/credentials");
|
var credentials = require("../../../../red/runtime/nodes/credentials");
|
||||||
var localfilesystem = require("../../../red/storage/localfilesystem");
|
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||||
var RED = require("../../../red/red.js");
|
var RED = require("../../../../red/red.js");
|
||||||
|
|
||||||
var userDir = path.join(__dirname,".testUserHome");
|
var userDir = path.join(__dirname,".testUserHome");
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
@ -114,7 +116,7 @@ describe("red/nodes/index", function() {
|
|||||||
}) ;
|
}) ;
|
||||||
RED.init(http.createServer(function(req,res){app(req,res)}),
|
RED.init(http.createServer(function(req,res){app(req,res)}),
|
||||||
{userDir: userDir});
|
{userDir: userDir});
|
||||||
server.start().then(function () {
|
runtime.start().then(function () {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -123,7 +125,7 @@ describe("red/nodes/index", function() {
|
|||||||
|
|
||||||
after(function(done) {
|
after(function(done) {
|
||||||
fs.remove(userDir,done);
|
fs.remove(userDir,done);
|
||||||
server.stop();
|
runtime.stop();
|
||||||
index.load.restore();
|
index.load.restore();
|
||||||
localfilesystem.getCredentials.restore();
|
localfilesystem.getCredentials.restore();
|
||||||
});
|
});
|
||||||
@ -142,7 +144,7 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
describe('allows nodes to be added/removed/enabled/disabled from the registry', function() {
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
@ -210,7 +212,7 @@ describe("red/nodes/index", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('allows modules to be removed from the registry', function() {
|
describe('allows modules to be removed from the registry', function() {
|
||||||
var registry = require("../../../red/nodes/registry");
|
var registry = require("../../../../red/runtime/nodes/registry");
|
||||||
var randomNodeInfo = {id:"5678",types:["random"]};
|
var randomNodeInfo = {id:"5678",types:["random"]};
|
||||||
var randomModuleInfo = {
|
var randomModuleInfo = {
|
||||||
name:"random",
|
name:"random",
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
|
|
||||||
var deprecated = require("../../../../red/nodes/registry/deprecated.js");
|
var deprecated = require("../../../../../red/runtime/nodes/registry/deprecated.js");
|
||||||
|
|
||||||
describe('deprecated', function() {
|
describe('deprecated', function() {
|
||||||
it('should return info on a node',function() {
|
it('should return info on a node',function() {
|
@ -19,10 +19,10 @@ var sinon = require("sinon");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
|
|
||||||
var RedNodes = require("../../../../red/nodes");
|
var RedNodes = require("../../../../../red/runtime/nodes");
|
||||||
var RedNode = require("../../../../red/nodes/Node");
|
var RedNode = require("../../../../../red/runtime/nodes/Node");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry");
|
||||||
var events = require("../../../../red/events");
|
var events = require("../../../../../red/runtime/events");
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
typeRegistry.clear();
|
typeRegistry.clear();
|
@ -20,9 +20,9 @@ var when = require("when");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var child_process = require('child_process');
|
var child_process = require('child_process');
|
||||||
var installer = require("../../../../red/nodes/registry/installer");
|
var installer = require("../../../../../red/runtime/nodes/registry/installer");
|
||||||
var registry = require("../../../../red/nodes/registry/index");
|
var registry = require("../../../../../red/runtime/nodes/registry/index");
|
||||||
var typeRegistry = require("../../../../red/nodes/registry/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry/registry");
|
||||||
|
|
||||||
describe('nodes/registry/installer', function() {
|
describe('nodes/registry/installer', function() {
|
||||||
|
|
@ -18,7 +18,7 @@ var should = require("should");
|
|||||||
var when = require("when");
|
var when = require("when");
|
||||||
var sinon = require("sinon");
|
var sinon = require("sinon");
|
||||||
|
|
||||||
var typeRegistry = require("../../../../red/nodes/registry/registry");
|
var typeRegistry = require("../../../../../red/runtime/nodes/registry/registry");
|
||||||
|
|
||||||
describe("red/nodes/registry/registry",function() {
|
describe("red/nodes/registry/registry",function() {
|
||||||
|
|
@ -16,7 +16,7 @@
|
|||||||
var should = require("should");
|
var should = require("should");
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
|
|
||||||
var settings = require("../../red/settings");
|
var settings = require("../../../red/runtime/settings");
|
||||||
|
|
||||||
|
|
||||||
describe("red/settings", function() {
|
describe("red/settings", function() {
|
||||||
@ -99,7 +99,6 @@ describe("red/settings", function() {
|
|||||||
(function() {
|
(function() {
|
||||||
settings.get("unknown");
|
settings.get("unknown");
|
||||||
}).should.throw();
|
}).should.throw();
|
||||||
|
|
||||||
settings.load(storage).then(function() {
|
settings.load(storage).then(function() {
|
||||||
settings.available().should.be.true;
|
settings.available().should.be.true;
|
||||||
settings.get("globalA").should.equal(789);
|
settings.get("globalA").should.equal(789);
|
@ -15,7 +15,7 @@
|
|||||||
**/
|
**/
|
||||||
var when = require("when");
|
var when = require("when");
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var storage = require("../../../red/storage/index");
|
var storage = require("../../../../red/runtime/storage/index");
|
||||||
|
|
||||||
describe("red/storage/index", function() {
|
describe("red/storage/index", function() {
|
||||||
|
|
@ -18,7 +18,7 @@ var should = require("should");
|
|||||||
var fs = require('fs-extra');
|
var fs = require('fs-extra');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
var localfilesystem = require("../../../red/storage/localfilesystem");
|
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
|
||||||
|
|
||||||
describe('LocalFileSystem', function() {
|
describe('LocalFileSystem', function() {
|
||||||
var userDir = path.join(__dirname,".testUserHome");
|
var userDir = path.join(__dirname,".testUserHome");
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
var should = require("should");
|
var should = require("should");
|
||||||
var util = require("../../red/util");
|
var util = require("../../../red/runtime/util");
|
||||||
|
|
||||||
describe("red/util", function() {
|
describe("red/util", function() {
|
||||||
describe('generateId', function() {
|
describe('generateId', function() {
|
Loading…
x
Reference in New Issue
Block a user