mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add support for file upload in /nodes api
This commit is contained in:
@@ -53,6 +53,7 @@ describe("api/admin/nodes", function() {
|
||||
describe('get nodes', function() {
|
||||
it('returns node list', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getNodeList: function() {
|
||||
return Promise.resolve([1,2,3]);
|
||||
@@ -75,6 +76,7 @@ describe("api/admin/nodes", function() {
|
||||
|
||||
it('returns node configs', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getNodeConfigs: function() {
|
||||
return Promise.resolve("<script></script>");
|
||||
@@ -99,6 +101,7 @@ describe("api/admin/nodes", function() {
|
||||
|
||||
it('returns node module info', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getModuleInfo: function(opts) {
|
||||
return Promise.resolve({"node-red":{name:"node-red"}}[opts.module]);
|
||||
@@ -119,6 +122,7 @@ describe("api/admin/nodes", function() {
|
||||
|
||||
it('returns 404 for unknown module', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getModuleInfo: function(opts) {
|
||||
var errInstance = new Error("Not Found");
|
||||
@@ -143,6 +147,7 @@ describe("api/admin/nodes", function() {
|
||||
|
||||
it('returns individual node info', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getNodeInfo: function(opts) {
|
||||
return Promise.resolve({"node-red/123":{id:"node-red/123"}}[opts.id]);
|
||||
@@ -164,6 +169,7 @@ describe("api/admin/nodes", function() {
|
||||
|
||||
it('returns individual node configs', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getNodeConfig: function(opts) {
|
||||
return Promise.resolve({"node-red/123":"<script></script>"}[opts.id]);
|
||||
@@ -187,6 +193,7 @@ describe("api/admin/nodes", function() {
|
||||
});
|
||||
it('returns 404 for unknown node', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getNodeInfo: function(opts) {
|
||||
var errInstance = new Error("Not Found");
|
||||
@@ -215,6 +222,7 @@ describe("api/admin/nodes", function() {
|
||||
it('installs the module and returns module info', function(done) {
|
||||
var opts;
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
addModule: function(_opts) {
|
||||
opts = _opts;
|
||||
@@ -244,6 +252,7 @@ describe("api/admin/nodes", function() {
|
||||
});
|
||||
it('returns error', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
addModule: function(opts) {
|
||||
var errInstance = new Error("Message");
|
||||
@@ -272,6 +281,7 @@ describe("api/admin/nodes", function() {
|
||||
it('uninstalls the module', function(done) {
|
||||
var opts;
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
removeModule: function(_opts) {
|
||||
opts = _opts;
|
||||
@@ -292,6 +302,7 @@ describe("api/admin/nodes", function() {
|
||||
});
|
||||
it('returns error', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
removeModule: function(opts) {
|
||||
var errInstance = new Error("Message");
|
||||
@@ -319,6 +330,7 @@ describe("api/admin/nodes", function() {
|
||||
describe('enable/disable node set', function() {
|
||||
it('returns 400 for invalid request payload', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
setNodeSetState: function(opts) {return Promise.resolve()}
|
||||
}
|
||||
@@ -340,6 +352,7 @@ describe("api/admin/nodes", function() {
|
||||
it('sets node state and returns node info', function(done) {
|
||||
var opts;
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
setNodeSetState: function(_opts) {
|
||||
opts = _opts;
|
||||
@@ -368,6 +381,7 @@ describe("api/admin/nodes", function() {
|
||||
describe('enable/disable module' ,function() {
|
||||
it('returns 400 for invalid request payload', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
setModuleState: function(opts) {return Promise.resolve()}
|
||||
}
|
||||
@@ -388,6 +402,7 @@ describe("api/admin/nodes", function() {
|
||||
it('sets module state and returns module info', function(done) {
|
||||
var opts;
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
setModuleState: function(_opts) {
|
||||
opts = _opts;
|
||||
@@ -416,6 +431,7 @@ describe("api/admin/nodes", function() {
|
||||
describe('get icons', function() {
|
||||
it('returns icon list', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getIconList: function() {
|
||||
return Promise.resolve({module:[1,2,3]});
|
||||
@@ -440,6 +456,7 @@ describe("api/admin/nodes", function() {
|
||||
describe('get module messages', function() {
|
||||
it('returns message catalog', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getModuleCatalog: function(opts) {
|
||||
return Promise.resolve({a:123});
|
||||
@@ -459,6 +476,7 @@ describe("api/admin/nodes", function() {
|
||||
});
|
||||
it('returns all node catalogs', function(done) {
|
||||
nodes.init({
|
||||
settings: {},
|
||||
nodes:{
|
||||
getModuleCatalogs: function(opts) {
|
||||
return Promise.resolve({a:1});
|
||||
|
@@ -18,7 +18,7 @@ var should = require("should");
|
||||
var sinon = require("sinon");
|
||||
var when = require("when");
|
||||
var path = require("path");
|
||||
var fs = require('fs');
|
||||
var fs = require('fs-extra');
|
||||
var EventEmitter = require('events');
|
||||
|
||||
var NR_TEST_UTILS = require("nr-test-utils");
|
||||
@@ -36,7 +36,7 @@ describe('nodes/registry/installer', function() {
|
||||
warn: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
metric: sinon.stub(),
|
||||
_: function() { return "abc"}
|
||||
_: function(msg) { return msg }
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
@@ -70,8 +70,8 @@ describe('nodes/registry/installer', function() {
|
||||
typeRegistry.getModuleInfo.restore();
|
||||
}
|
||||
|
||||
if (require('fs').statSync.restore) {
|
||||
require('fs').statSync.restore();
|
||||
if (fs.statSync.restore) {
|
||||
fs.statSync.restore();
|
||||
}
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user