Fixup all the tests

This commit is contained in:
Nick O'Leary
2018-08-20 16:17:24 +01:00
parent 998bf92ad4
commit 38a1291c5b
113 changed files with 458 additions and 250 deletions

View File

@@ -21,9 +21,11 @@ var bodyParser = require('body-parser');
var sinon = require('sinon');
var when = require('when');
var context = require("../../../../red/api/admin/context");
var Context = require("../../../../red/runtime/nodes/context");
var Util = require("../../../../red/runtime/util");
var NR_TEST_UTILS = require("nr-test-utils");
var context = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/context");
// var Context = require("../../../../red/runtime/nodes/context");
// var Util = require("../../../../red/runtime/util");
describe("api/admin/context", function() {
it.skip("NEEDS TESTS WRITING",function() {});

View File

@@ -21,7 +21,9 @@ var bodyParser = require('body-parser');
var sinon = require('sinon');
var when = require('when');
var flow = require("../../../../red/api/admin/flow");
var NR_TEST_UTILS = require("nr-test-utils");
var flow = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/flow");
describe("api/admin/flow", function() {

View File

@@ -20,7 +20,9 @@ var express = require('express');
var bodyParser = require('body-parser');
var sinon = require('sinon');
var flows = require("../../../../red/api/admin/flows");
var NR_TEST_UTILS = require("nr-test-utils");
var flows = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/flows");
describe("api/admin/flows", function() {

View File

@@ -18,12 +18,14 @@ var should = require("should");
var sinon = require("sinon");
var request = require("supertest");
var express = require("express");
var adminApi = require("../../../../red/api/admin");
var auth = require("../../../../red/api/auth");
var nodes = require("../../../../red/api/admin/nodes");
var flows = require("../../../../red/api/admin/flows");
var flow = require("../../../../red/api/admin/flow");
var NR_TEST_UTILS = require("nr-test-utils");
var adminApi = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin");
var auth = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth");
var nodes = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/nodes");
var flows = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/flows");
var flow = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/flow");
/**
* Ensure all API routes are correctly mounted, with the expected permissions checks

View File

@@ -21,8 +21,10 @@ var bodyParser = require('body-parser');
var sinon = require('sinon');
var when = require('when');
var nodes = require("../../../../red/api/admin/nodes");
var apiUtil = require("../../../../red/api/util");
var NR_TEST_UTILS = require("nr-test-utils");
var nodes = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin/nodes");
var apiUtil = NR_TEST_UTILS.require("@node-red/editor-api/lib/util");
describe("api/admin/nodes", function() {

View File

@@ -15,7 +15,8 @@
**/
var should = require("should");
var Clients = require("../../../../red/api/auth/clients");
var NR_TEST_UTILS = require("nr-test-utils");
var Clients = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/clients");
describe("api/auth/clients", function() {
it('finds the known editor client',function(done) {

View File

@@ -20,10 +20,12 @@ var sinon = require("sinon");
var passport = require("passport");
var auth = require("../../../../red/api/auth");
var Users = require("../../../../red/api/auth/users");
var Tokens = require("../../../../red/api/auth/tokens");
var Permissions = require("../../../../red/api/auth/permissions");
var NR_TEST_UTILS = require("nr-test-utils");
var auth = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth");
var Users = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/users");
var Tokens = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/tokens");
var Permissions = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/permissions");
describe("api/auth/index",function() {

View File

@@ -15,7 +15,10 @@
**/
var should = require("should");
var permissions = require("../../../../red/api/auth/permissions");
var NR_TEST_UTILS = require("nr-test-utils");
var permissions = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/permissions");
describe("api/auth/permissions", function() {
describe("hasPermission", function() {

View File

@@ -18,10 +18,12 @@ var should = require("should");
var when = require('when');
var sinon = require('sinon');
var strategies = require("../../../../red/api/auth/strategies");
var Users = require("../../../../red/api/auth/users");
var Tokens = require("../../../../red/api/auth/tokens");
var Clients = require("../../../../red/api/auth/clients");
var NR_TEST_UTILS = require("nr-test-utils");
var strategies = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/strategies");
var Users = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/users");
var Tokens = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/tokens");
var Clients = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/clients");
describe("api/auth/strategies", function() {
describe("Password Token Exchange", function() {

View File

@@ -18,7 +18,9 @@ var should = require("should");
var when = require("when");
var sinon = require("sinon");
var Tokens = require("../../../../red/api/auth/tokens");
var NR_TEST_UTILS = require("nr-test-utils");
var Tokens = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/tokens");
describe("api/auth/tokens", function() {

View File

@@ -18,7 +18,9 @@ var should = require("should");
var when = require('when');
var sinon = require('sinon');
var Users = require("../../../../red/api/auth/users");
var NR_TEST_UTILS = require("nr-test-utils");
var Users = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/users");
describe("api/auth/users", function() {
after(function() {

View File

@@ -24,9 +24,11 @@ var express = require('express');
var app = express();
var WebSocket = require('ws');
var comms = require("../../../../red/api/editor/comms");
var Users = require("../../../../red/api/auth/users");
var Tokens = require("../../../../red/api/auth/tokens");
var NR_TEST_UTILS = require("nr-test-utils");
var comms = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/comms");
var Users = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/users");
var Tokens = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth/tokens");
var address = '127.0.0.1';
var listenPort = 0; // use ephemeral port

View File

@@ -20,7 +20,9 @@ var express = require('express');
var sinon = require('sinon');
var when = require('when');
var credentials = require("../../../../red/api/editor/credentials");
var NR_TEST_UTILS = require("nr-test-utils");
var credentials = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/credentials");
describe('api/editor/credentials', function() {
var app;

View File

@@ -18,12 +18,15 @@ var should = require("should");
var sinon = require("sinon");
var request = require("supertest");
var express = require("express");
var editorApi = require("../../../../red/api/editor");
var comms = require("../../../../red/api/editor/comms");
var info = require("../../../../red/api/editor/settings");
var auth = require("../../../../red/api/auth");
var log = require("../../../../red/util/log");
var NR_TEST_UTILS = require("nr-test-utils");
var editorApi = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor");
var comms = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/comms");
var info = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/settings");
var auth = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth");
var log = NR_TEST_UTILS.require("@node-red/util").log;
var when = require("when");
@@ -59,15 +62,15 @@ describe("api/editor/index", function() {
return function(req,res,next) { next(); }
});
mockList.forEach(function(m) {
sinon.stub(require("../../../../red/api/editor/"+m),"init",function(){});
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/"+m),"init",function(){});
});
sinon.stub(require("../../../../red/api/editor/theme"),"app",function(){ return express()});
sinon.stub(NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme"),"app",function(){ return express()});
});
after(function() {
mockList.forEach(function(m) {
require("../../../../red/api/editor/"+m).init.restore();
NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/"+m).init.restore();
})
require("../../../../red/api/editor/theme").app.restore();
NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme").app.restore();
auth.needsPermission.restore();
log.error.restore();
});
@@ -93,9 +96,12 @@ describe("api/editor/index", function() {
});
it('serves icons', function(done) {
request(app)
.get("/icons/inject.png")
.get("/red/images/icons/node-changed.png")
.expect(200)
.expect("Content-Type", /image\/png/)
.expect(200,done)
.end(function(err,res) {
done(err);
});
});
it('handles page not there', function(done) {
request(app)

View File

@@ -20,9 +20,11 @@ var request = require('supertest');
var express = require('express');
var bodyParser = require('body-parser');
var app;
var NR_TEST_UTILS = require("nr-test-utils");
var library = require("../../../../red/api/editor/library");
var library = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/library");
var app;
describe("api/editor/library", function() {

View File

@@ -19,8 +19,10 @@ var request = require('supertest');
var express = require('express');
var sinon = require('sinon');
var locales = require("../../../../red/api/editor/locales");
var i18n = require("../../../../red/util").i18n;
var NR_TEST_UTILS = require("nr-test-utils");
var locales = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/locales");
var i18n = NR_TEST_UTILS.require("@node-red/util").i18n;
describe("api/editor/locales", function() {
beforeEach(function() {

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("api/editor/projects", function() {
it.skip("NEEDS TESTS WRITING",function() {});
});

View File

@@ -21,8 +21,11 @@ var bodyParser = require("body-parser");
var sinon = require('sinon');
var app;
var info = require("../../../../red/api/editor/settings");
var theme = require("../../../../red/api/editor/theme");
var NR_TEST_UTILS = require("nr-test-utils");
var info = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/settings");
var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
describe("api/editor/settings", function() {
before(function() {

View File

@@ -18,7 +18,8 @@ var should = require("should");
var sinon = require("sinon");
var request = require("supertest");
var express = require("express");
var sshkeys = require("../../../../red/api/editor/sshkeys");
var NR_TEST_UTILS = require("nr-test-utils");
var sshkeys = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/sshkeys");
var bodyParser = require("body-parser");

View File

@@ -22,7 +22,9 @@ var fs = require("fs");
var app = express();
var theme = require("../../../../red/api/editor/theme");
var NR_TEST_UTILS = require("nr-test-utils");
var theme = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/theme");
describe("api/editor/theme", function() {
beforeEach(function() {

View File

@@ -20,7 +20,9 @@ var express = require("express");
var fs = require("fs");
var path = require("path");
var ui = require("../../../../red/api/editor/ui");
var NR_TEST_UTILS = require("nr-test-utils");
var ui = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor/ui");
describe("api/editor/ui", function() {
@@ -31,7 +33,7 @@ describe("api/editor/ui", function() {
nodes: {
getIcon: function(opts) {
return new Promise(function(resolve,reject) {
fs.readFile(path.resolve(__dirname+'/../../../../public/icons/arrow-in.png'), function(err,data) {
fs.readFile(NR_TEST_UTILS.resolve("@node-red/editor-client/src/images/icons/arrow-in.png"), function(err,data) {
resolve(data);
})
});
@@ -92,7 +94,7 @@ describe("api/editor/ui", function() {
}
}
it('returns the requested icon', function(done) {
var defaultIcon = fs.readFileSync(path.resolve(__dirname+'/../../../../public/icons/arrow-in.png'));
var defaultIcon = fs.readFileSync(NR_TEST_UTILS.resolve("@node-red/editor-client/src/images/icons/arrow-in.png"));
request(app)
.get("/icons/module/icon.png")
.expect("Content-Type", /image\/png/)

View File

@@ -21,11 +21,14 @@ var express = require("express");
var when = require("when");
var fs = require("fs");
var path = require("path");
var api = require("../../../red/api");
var apiAuth = require("../../../red/api/auth");
var apiEditor = require("../../../red/api/editor");
var apiAdmin = require("../../../red/api/admin");
var NR_TEST_UTILS = require("nr-test-utils");
var api = NR_TEST_UTILS.require("@node-red/editor-api");
var apiAuth = NR_TEST_UTILS.require("@node-red/editor-api/lib/auth");
var apiEditor = NR_TEST_UTILS.require("@node-red/editor-api/lib/editor");
var apiAdmin = NR_TEST_UTILS.require("@node-red/editor-api/lib/admin");
describe("api/index", function() {

View File

@@ -19,12 +19,12 @@ var sinon = require("sinon");
var request = require('supertest');
var express = require('express');
var apiUtil = require("../../../red/api/util");
var log = require("../../../red/util").log; // TODO: separate module
var i18n = require("../../../red/util").i18n; // TODO: separate module
var NR_TEST_UTILS = require("nr-test-utils");
var apiUtil = NR_TEST_UTILS.require("@node-red/editor-api/lib/util");
var log = NR_TEST_UTILS.require("@node-red/util").log;
var i18n = NR_TEST_UTILS.require("@node-red/util").i18n;
describe("api/util", function() {
describe("errorHandler", function() {

View File

@@ -16,7 +16,9 @@
var should = require("should");
var deprecated = require("../../../red/runtime-registry/deprecated.js");
var NR_TEST_UTILS = require("nr-test-utils");
var deprecated = NR_TEST_UTILS.require("@node-red/registry/lib/deprecated.js");
describe('deprecated', function() {
it('should return info on a node',function() {

View File

@@ -20,11 +20,13 @@ var path = require("path");
var when = require("when");
var fs = require("fs");
var registry = require("../../../red/runtime-registry");
var NR_TEST_UTILS = require("nr-test-utils");
var installer = require("../../../red/runtime-registry/installer");
var loader = require("../../../red/runtime-registry/loader");
var typeRegistry = require("../../../red/runtime-registry/registry");
var registry = NR_TEST_UTILS.require("@node-red/registry");
var installer = NR_TEST_UTILS.require("@node-red/registry/lib/installer");
var loader = NR_TEST_UTILS.require("@node-red/registry/lib/loader");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry/lib/registry");
describe('red/registry/index', function() {
var stubs = [];

View File

@@ -22,9 +22,13 @@ var fs = require('fs');
var EventEmitter = require('events');
var child_process = require('child_process');
var installer = require("../../../red/runtime-registry/installer");
var registry = require("../../../red/runtime-registry/index");
var typeRegistry = require("../../../red/runtime-registry/registry");
var NR_TEST_UTILS = require("nr-test-utils");
var installer = NR_TEST_UTILS.require("@node-red/registry/lib/installer");
var registry = NR_TEST_UTILS.require("@node-red/registry/lib/index");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry/lib/registry");
describe('nodes/registry/installer', function() {

View File

@@ -19,7 +19,9 @@ var should = require("should");
var fs = require("fs");
var path = require("path");
var library = require("../../../red/runtime-registry/library");
var NR_TEST_UTILS = require("nr-test-utils");
var library = NR_TEST_UTILS.require("@node-red/registry/lib/library");
describe("library api", function() {
it('returns null list when no modules have been registered', function() {

View File

@@ -20,12 +20,14 @@ var sinon = require("sinon");
var path = require("path");
var fs = require("fs");
var loader = require("../../../red/runtime-registry/loader");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystem = require("../../../red/runtime-registry/localfilesystem");
var registry = require("../../../red/runtime-registry/registry");
var loader = NR_TEST_UTILS.require("@node-red/registry/lib/loader");
var nodes = require("../../../red/runtime-registry");
var localfilesystem = NR_TEST_UTILS.require("@node-red/registry/lib/localfilesystem");
var registry = NR_TEST_UTILS.require("@node-red/registry/lib/registry");
var nodes = NR_TEST_UTILS.require("@node-red/registry");
var resourcesDir = path.resolve(path.join(__dirname,"resources","local"));

View File

@@ -19,13 +19,15 @@ var when = require("when");
var sinon = require("sinon");
var path = require("path");
var localfilesystem = require("../../../red/runtime-registry/localfilesystem");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystem = NR_TEST_UTILS.require("@node-red/registry/lib/localfilesystem");
var resourcesDir = path.resolve(path.join(__dirname,"resources","local"));
var userDir = path.resolve(path.join(__dirname,"resources","userDir"));
var moduleDir = path.resolve(path.join(__dirname,"resources","local","TestNodeModule"));
var i18n = require("../../../red/util").i18n; // TODO: separate module
var i18n = NR_TEST_UTILS.require("@node-red/util").i18n;
describe("red/nodes/registry/localfilesystem",function() {
beforeEach(function() {
@@ -108,7 +110,8 @@ describe("red/nodes/registry/localfilesystem",function() {
done();
});
it("Finds nodes in settings.nodesDir (string,relative path)",function(done) {
var relativeUserDir = path.join("test","red","runtime-registry","resources","userDir");
var relativeUserDir = path.join("test","unit","@node-red","registry","lib","resources","userDir");
console.log(relativeUserDir)
localfilesystem.init({settings:{nodesDir:relativeUserDir}});
var nodeList = localfilesystem.getNodeFiles(true);
nodeList.should.have.a.property("node-red");
@@ -186,11 +189,11 @@ describe("red/nodes/registry/localfilesystem",function() {
var list = localfilesystem.getNodeFiles(true);
list.should.have.property("node-red");
list["node-red"].should.have.property("icons");
list["node-red"].icons.should.have.length(2);
list["node-red"].icons[1].should.have.property("path",path.join(__dirname,"resources/local/NestedDirectoryNode/NestedNode/icons"))
list["node-red"].icons[1].should.have.property("icons");
list["node-red"].icons[1].icons.should.have.length(1);
list["node-red"].icons[1].icons[0].should.eql("arrow-in.png");
list["node-red"].icons.should.have.length(1);
list["node-red"].icons[0].should.have.property("path",path.join(__dirname,"resources/local/NestedDirectoryNode/NestedNode/icons"))
list["node-red"].icons[0].should.have.property("icons");
list["node-red"].icons[0].icons.should.have.length(1);
list["node-red"].icons[0].icons[0].should.eql("arrow-in.png");
done();
});
it("scans icons dir in library",function(done) {
@@ -216,11 +219,11 @@ describe("red/nodes/registry/localfilesystem",function() {
var list = localfilesystem.getNodeFiles(true);
list.should.have.property("node-red");
list["node-red"].should.have.property("icons");
list["node-red"].icons.should.have.length(2);
list["node-red"].icons[1].should.have.property("path",path.join(__dirname,"resources/userDir/lib/icons"))
list["node-red"].icons[1].should.have.property("icons");
list["node-red"].icons[1].icons.should.have.length(1);
list["node-red"].icons[1].icons[0].should.eql("test_icon.png");
list["node-red"].icons.should.have.length(1);
list["node-red"].icons[0].should.have.property("path",path.join(__dirname,"resources/userDir/lib/icons"))
list["node-red"].icons[0].should.have.property("icons");
list["node-red"].icons[0].icons.should.have.length(1);
list["node-red"].icons[0].icons[0].should.eql("test_icon.png");
done();
});
});

View File

@@ -19,7 +19,9 @@ var when = require("when");
var sinon = require("sinon");
var path = require("path");
var typeRegistry = require("../../../red/runtime-registry/registry");
var NR_TEST_UTILS = require("nr-test-utils");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry/lib/registry");
var EventEmitter = require('events');
var events = new EventEmitter();
@@ -518,10 +520,9 @@ describe("red/nodes/registry/registry",function() {
});
describe('#getNodeIconPath', function() {
it('returns the default icon when getting an unknown icon', function() {
var defaultIcon = path.resolve(__dirname+'/../../../public/icons/arrow-in.png');
it('returns the null when getting an unknown icon', function() {
var iconPath = typeRegistry.getNodeIconPath('random-module','youwonthaveme.png');
iconPath.should.eql(defaultIcon);
should.not.exist(iconPath);
});
it('returns a registered icon' , function() {
@@ -543,10 +544,10 @@ describe("red/nodes/registry/registry",function() {
iconPath.should.eql(path.resolve(testIcon+"/test_icon.png"));
});
it('returns the debug icon when getting an unknown module', function() {
it('returns null when getting an unknown module', function() {
var debugIcon = path.resolve(__dirname+'/../../../public/icons/debug.png');
var iconPath = typeRegistry.getNodeIconPath('unknown-module', 'debug.png');
iconPath.should.eql(debugIcon);
should.not.exist(iconPath);
});
});

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var comms = require("../../../red/runtime-api/comms");
var NR_TEST_UTILS = require("nr-test-utils");
var comms = NR_TEST_UTILS.require("@node-red/runtime/lib/api/comms");
describe("runtime-api/comms", function() {
describe("listens for events", function() {

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("runtime-api/context", function() {
it.skip("NEEDS TESTS WRITING",function() {});
});

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var flows = require("../../../red/runtime-api/flows")
var NR_TEST_UTILS = require("nr-test-utils");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/api/flows")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -17,18 +17,19 @@
var should = require("should");
var sinon = require("sinon");
var index = require("../../../red/runtime-api/index");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/api/index");
describe("runtime-api/index", function() {
before(function() {
["comms","flows","nodes","settings","library","projects"].forEach(n => {
sinon.stub(require(`../../../red/runtime-api/${n}`),"init",()=>{});
sinon.stub(NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`),"init",()=>{});
})
});
after(function() {
["comms","flows","nodes","settings","library","projects"].forEach(n => {
require(`../../../red/runtime-api/${n}`).init.restore()
NR_TEST_UTILS.require(`@node-red/runtime/lib/api/${n}`).init.restore()
})
})
it('isStarted', function(done) {

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var library = require("../../../red/runtime-api/library")
var NR_TEST_UTILS = require("nr-test-utils");
var library = NR_TEST_UTILS.require("@node-red/runtime/lib/api/library")
var mockLog = {
log: sinon.stub(),

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var nodes = require("../../../red/runtime-api/nodes")
var NR_TEST_UTILS = require("nr-test-utils");
var nodes = NR_TEST_UTILS.require("@node-red/runtime/lib/api/nodes")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var projects = require("../../../red/runtime-api/projects")
var NR_TEST_UTILS = require("nr-test-utils");
var projects = NR_TEST_UTILS.require("@node-red/runtime/lib/api/projects")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -18,7 +18,8 @@
var should = require("should");
var sinon = require("sinon");
var settings = require("../../../red/runtime-api/settings")
var NR_TEST_UTILS = require("nr-test-utils");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/api/settings")
var mockLog = () => ({
log: sinon.stub(),

View File

@@ -15,9 +15,11 @@
**/
var should = require("should");
var NR_TEST_UTILS = require("nr-test-utils");
describe("runtime/events", function() {
it('can be required without errors', function() {
require("../../../red/runtime/events");
NR_TEST_UTILS.require("@node-red/runtime/lib/events");
});
it.skip('more tests needed', function(){})
});

View File

@@ -17,13 +17,15 @@ var should = require("should");
var sinon = require("sinon");
var path = require("path");
var api = require("../../../red/api");
var runtime = require("../../../red/runtime");
var NR_TEST_UTILS = require("nr-test-utils");
var redNodes = require("../../../red/runtime/nodes");
var storage = require("../../../red/runtime/storage");
var settings = require("../../../red/runtime/settings");
var log = require("../../../red/util/log");
var api = NR_TEST_UTILS.require("@node-red/runtime/lib/api");
var runtime = NR_TEST_UTILS.require("@node-red/runtime");
var redNodes = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes");
var storage = NR_TEST_UTILS.require("@node-red/runtime/lib/storage");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/settings");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe("runtime", function() {
afterEach(function() {
@@ -33,7 +35,7 @@ describe("runtime", function() {
})
before(function() {
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..",".."))
process.env.NODE_RED_HOME = NR_TEST_UTILS.resolve("node-red");
});
after(function() {
delete process.env.NODE_RED_HOME;
@@ -75,7 +77,10 @@ describe("runtime", function() {
it("returns version", function() {
runtime.init({testSettings: true, httpAdminRoot:"/"},mockUtil());
/^\d+\.\d+\.\d+(-git)?$/.test(runtime.version()).should.be.true();
return runtime.version().then(version => {
/^\d+\.\d+\.\d+(-git)?$/.test(version).should.be.true();
});
})
});

View File

@@ -18,7 +18,8 @@ var should = require("should");
var sinon = require("sinon");
var fs = require("fs");
var library = require("../../../../red/runtime/library/index")
var NR_TEST_UTILS = require("nr-test-utils");
var library = NR_TEST_UTILS.require("@node-red/runtime/lib/library/index")
var mockLog = {
log: sinon.stub(),

View File

@@ -16,9 +16,10 @@
var should = require("should");
var sinon = require('sinon');
var RedNode = require("../../../../red/runtime/nodes/Node");
var Log = require("../../../../red/util/log");
var flows = require("../../../../red/runtime/nodes/flows");
var NR_TEST_UTILS = require("nr-test-utils");
var RedNode = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var Log = NR_TEST_UTILS.require("@node-red/util").log;
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
describe('Node', function() {
describe('#constructor',function() {

View File

@@ -18,7 +18,8 @@ var should = require("should");
var sinon = require('sinon');
var path = require("path");
var fs = require('fs-extra');
var Context = require("../../../../../red/runtime/nodes/context/index");
var NR_TEST_UTILS = require("nr-test-utils");
var Context = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/index");
describe('context', function() {
describe('local memory',function() {

View File

@@ -17,7 +17,8 @@
var should = require('should');
var fs = require('fs-extra');
var path = require("path");
var LocalFileSystem = require('../../../../../red/runtime/nodes/context/localfilesystem');
var NR_TEST_UTILS = require("nr-test-utils");
var LocalFileSystem = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/localfilesystem");
var resourcesDir = path.resolve(path.join(__dirname,"..","resources","context"));

View File

@@ -15,7 +15,9 @@
**/
var should = require('should');
var Memory = require('../../../../../red/runtime/nodes/context/memory');
var NR_TEST_UTILS = require("nr-test-utils");
var Memory = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/context/memory");
describe('memory',function() {
var context;

View File

@@ -19,9 +19,10 @@ var sinon = require("sinon");
var when = require("when");
var util = require("util");
var index = require("../../../../red/runtime/nodes/index");
var credentials = require("../../../../red/runtime/nodes/credentials");
var log = require("../../../../red/util/log");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/index");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe('red/runtime/nodes/credentials', function() {

View File

@@ -20,11 +20,13 @@ var sinon = require('sinon');
var clone = require('clone');
var util = require("util");
var flowUtils = require("../../../../../red/runtime/nodes/flows/util");
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
var flows = require("../../../../../red/runtime/nodes/flows");
var Node = require("../../../../../red/runtime/nodes/Node");
var typeRegistry = require("../../../../../red/runtime-registry");
var NR_TEST_UTILS = require("nr-test-utils");
var flowUtils = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/util");
var Flow = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/Flow");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var Node = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry");
describe('Flow', function() {

View File

@@ -18,13 +18,15 @@ var should = require("should");
var sinon = require("sinon");
var when = require("when");
var clone = require("clone");
var flows = require("../../../../../red/runtime/nodes/flows");
var RedNode = require("../../../../../red/runtime/nodes/Node");
var RED = require("../../../../../red/runtime/nodes");
var events = require("../../../../../red/runtime/events");
var credentials = require("../../../../../red/runtime/nodes/credentials");
var typeRegistry = require("../../../../../red/runtime-registry");
var Flow = require("../../../../../red/runtime/nodes/flows/Flow");
var NR_TEST_UTILS = require("nr-test-utils");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var RedNode = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
var RED = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes");
var events = NR_TEST_UTILS.require("@node-red/runtime/lib/events");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry")
var Flow = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/Flow");
describe('flows/index', function() {

View File

@@ -18,9 +18,10 @@ var should = require("should");
var sinon = require("sinon");
var when = require("when");
var clone = require("clone");
var flowUtil = require("../../../../../red/runtime/nodes/flows/util");
var typeRegistry = require("../../../../../red/runtime-registry");
var redUtil = require("../../../../../red/runtime/util");
var NR_TEST_UTILS = require("nr-test-utils");
var flowUtil = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows/util");
var typeRegistry = NR_TEST_UTILS.require("@node-red/registry");
var redUtil = NR_TEST_UTILS.require("@node-red/util").util;
describe('flows/util', function() {
var getType;

View File

@@ -21,15 +21,16 @@ var when = require("when");
var sinon = require('sinon');
var inherits = require("util").inherits;
var index = require("../../../../red/runtime/nodes/index");
var flows = require("../../../../red/runtime/nodes/flows");
var registry = require("../../../../red/runtime-registry");
var Node = require("../../../../red/runtime/nodes/Node");
var NR_TEST_UTILS = require("nr-test-utils");
var index = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/index");
var flows = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/flows");
var registry = NR_TEST_UTILS.require("@node-red/registry")
var Node = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/Node");
describe("red/nodes/index", function() {
before(function() {
sinon.stub(index,"startFlows");
process.env.NODE_RED_HOME = path.resolve(path.join(__dirname,"..","..","..",".."))
process.env.NODE_RED_HOME = NR_TEST_UTILS.resolve("node-red");
});
after(function() {
index.startFlows.restore();
@@ -168,11 +169,11 @@ describe("red/nodes/index", function() {
var http = require('http');
var express = require('express');
var app = express();
var runtime = require("../../../../red/runtime");
var credentials = require("../../../../red/runtime/nodes/credentials");
var localfilesystem = require("../../../../red/runtime/storage/localfilesystem");
var log = require("../../../../red/util/log");
var RED = require("../../../../red/red.js");
var runtime = NR_TEST_UTILS.require("@node-red/runtime");
var credentials = NR_TEST_UTILS.require("@node-red/runtime/lib/nodes/credentials");
var localfilesystem = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem");
var log = NR_TEST_UTILS.require("@node-red/util").log;
var RED = NR_TEST_UTILS.require("node-red/lib/red.js");
var userDir = path.join(__dirname,".testUserHome");
before(function(done) {

View File

@@ -15,7 +15,8 @@
**/
var should = require("should");
var settings = require("../../../red/runtime/settings");
var NR_TEST_UTILS = require("nr-test-utils");
var settings = NR_TEST_UTILS.require("@node-red/runtime/lib/settings");
describe("red/settings", function() {

View File

@@ -16,7 +16,10 @@
var when = require("when");
var should = require("should");
var paff = require('path');
var storage = require("../../../../red/runtime/storage/index");
var NR_TEST_UTILS = require("nr-test-utils");
var storage = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/index");
describe("red/storage/index", function() {

View File

@@ -18,9 +18,10 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var sinon = require('sinon');
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystem = require("../../../../../red/runtime/storage/localfilesystem");
var log = require("../../../../../red/util/log");
var localfilesystem = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe('storage/localfilesystem', function() {
var mockRuntime = {

View File

@@ -17,8 +17,9 @@
var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemLibrary = require("../../../../../red/runtime/storage/localfilesystem/library");
var localfilesystemLibrary = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/library");
describe('storage/localfilesystem/library', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/Project", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -16,7 +16,8 @@
var should = require("should");
var defaultFileSet = require("../../../../../../red/runtime/storage/localfilesystem/projects/defaultFileSet");
var NR_TEST_UTILS = require("nr-test-utils");
var defaultFileSet = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/defaultFileSet");
describe('storage/localfilesystem/projects/defaultFileSet', function() {
var runtime = {

View File

@@ -17,7 +17,8 @@
var should = require("should");
var sinon = require("sinon");
var authCache = require("../../../../../../../red/runtime/storage/localfilesystem/projects/git/authCache")
var NR_TEST_UTILS = require("nr-test-utils");
var authCache = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/git/authCache")
describe("localfilesystem/projects/git/authCache", function() {

View File

@@ -22,7 +22,9 @@ var sinon = require("sinon");
var child_process = require("child_process");
var fs = require("fs-extra");
var authServer = require("../../../../../../../red/runtime/storage/localfilesystem/projects/git/authServer");
var NR_TEST_UTILS = require("nr-test-utils");
var authServer = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/git/authServer");
var sendPrompt = function(localPath, prompt) {

View File

@@ -22,7 +22,9 @@ var sinon = require("sinon");
var child_process = require("child_process");
var fs = require("fs-extra");
var authWriter = "../../../../../../../red/runtime/storage/localfilesystem/projects/git/authWriter";
var NR_TEST_UTILS = require("nr-test-utils");
var authWriter = NR_TEST_UTILS.resolve("@node-red/runtime/lib/storage/localfilesystem/projects/git/authWriter");
function getListenPath() {
var seed = (0x100000+Math.random()*0x999999).toString(16);

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/git/index", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -14,6 +14,8 @@
* limitations under the License.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("storage/localfilesystem/projects/index", function() {
it.skip("NEEDS TESTS WRITING",function() {});
})

View File

@@ -17,7 +17,8 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var sshkeys = require("../../../../../../../red/runtime/storage/localfilesystem/projects/ssh");
var NR_TEST_UTILS = require("nr-test-utils");
var sshkeys = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/ssh");
describe("storage/localfilesystem/projects/ssh", function() {
var userDir = path.join(__dirname,".testSSHKeyUserHome");

View File

@@ -19,7 +19,8 @@ var sinon = require("sinon");
var child_process = require('child_process');
var EventEmitter = require("events");
var keygen = require("../../../../../../../red/runtime/storage/localfilesystem/projects/ssh/keygen")
var NR_TEST_UTILS = require("nr-test-utils");
var keygen = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/projects/ssh/keygen")
describe("localfilesystem/projects/ssh/keygen", function() {

View File

@@ -18,7 +18,8 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var localfilesystemSessions = require("../../../../../red/runtime/storage/localfilesystem/sessions");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemSessions = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/sessions");
describe('storage/localfilesystem/sessions', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -18,7 +18,9 @@ var should = require("should");
var fs = require('fs-extra');
var path = require('path');
var localfilesystemSettings = require("../../../../../red/runtime/storage/localfilesystem/settings");
var NR_TEST_UTILS = require("nr-test-utils");
var localfilesystemSettings = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/settings");
describe('storage/localfilesystem/settings', function() {
var userDir = path.join(__dirname,".testUserHome");

View File

@@ -15,7 +15,8 @@
**/
var should = require("should");
var util = require("../../../../../red/runtime/storage/localfilesystem/util");
var NR_TEST_UTILS = require("nr-test-utils");
var util = NR_TEST_UTILS.require("@node-red/runtime/lib/storage/localfilesystem/util");
describe('storage/localfilesystem/util', function() {
describe('parseJSON', function() {

View File

@@ -0,0 +1,21 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("node-red/red", function() {
it.skip("NEEDS TESTS WRITING",function() {});
});

View File

@@ -14,9 +14,13 @@
* limitations under the License.
**/
describe("util/i18n", function() {
it('can be required without errors', function() {
require("../../../red/util/i18n");
});
var NR_TEST_UTILS = require("nr-test-utils");
var i18n = NR_TEST_UTILS.require("@node-red/util").i18n;
describe("@node-red/util/i18n", function() {
it.skip('more tests needed', function(){})
});

View File

@@ -14,6 +14,6 @@
* limitations under the License.
**/
describe("util", function() {
describe("@node-red/util", function() {
it.skip('more tests needed', function(){})
});

View File

@@ -16,9 +16,13 @@
var should = require("should");
var sinon = require("sinon");
var util = require("util");
var log = require("../../../red/util/log");
describe("util/log", function() {
var NR_TEST_UTILS = require("nr-test-utils");
var log = NR_TEST_UTILS.require("@node-red/util").log;
describe("@node-red/util/log", function() {
beforeEach(function () {
var spy = sinon.stub(util, 'log', function(arg){});
var settings = {logging: { console: { level: 'metric', metrics: true } } };

View File

@@ -14,9 +14,12 @@
* limitations under the License.
**/
var should = require("should");
var util = require("../../../red/runtime/util");
describe("red/util", function() {
var NR_TEST_UTILS = require("nr-test-utils");
var util = NR_TEST_UTILS.require("@node-red/util").util;
describe("@node-red/util/util", function() {
describe('generateId', function() {
it('generates an id', function() {
var id = util.generateId();

View File

@@ -18,9 +18,15 @@ var sinon = require("sinon");
var fs = require("fs");
var path = require("path");
var RED = require("../../red/red");
var runtime = require("../../red/runtime");
var api = require("../../red/api");
var NR_TEST_UTILS = require("nr-test-utils");
var api = NR_TEST_UTILS.require("@node-red/runtime/lib/api");
var RED = NR_TEST_UTILS.require("node-red");
var runtime = NR_TEST_UTILS.require("@node-red/runtime");
var api = NR_TEST_UTILS.require("@node-red/runtime/lib/api");
describe("red/red", function() {
@@ -37,7 +43,7 @@ describe("red/red", function() {
fs.statSync.restore();
RED.version.restore();
});
it('warns if build has not been run',function() {
it.skip('warns if build has not been run',function() {
sinon.stub(fs,"statSync",function() { throw new Error();});
/*jshint immed: false */
@@ -53,15 +59,14 @@ describe("red/red", function() {
describe("externals", function() {
it('reports version', function() {
var p = require(path.join(process.env.NODE_RED_HOME,"package.json")).version;
RED.version().indexOf(p).should.eql(0);
/\d+\.\d+\.\d+(-git)?/.test(RED.version()).should.be.true();
});
it.skip('access server externals', function() {
// TODO: unstubable accessors - need to make this testable
RED.app;
RED.httpAdmin;
RED.httpNode;
RED.server;
// RED.app;
// RED.httpAdmin;
// RED.httpNode;
// RED.server;
});
it.skip('only initialises api component if httpAdmin enabled');
it.skip('stubs httpAdmin if httpAdmin disabled');

View File

@@ -0,0 +1,21 @@
/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* 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.
**/
var NR_TEST_UTILS = require("nr-test-utils");
describe("node-red/red", function() {
it.skip("NEEDS TESTS WRITING",function() {});
});