mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Fixup all the tests
This commit is contained in:
@@ -42,9 +42,6 @@ var stubbedExpressApp = {
|
||||
delete: function() {}
|
||||
}
|
||||
var adminApi = {
|
||||
library: {
|
||||
register: function() {}
|
||||
},
|
||||
auth: {
|
||||
needsPermission: function() {}
|
||||
},
|
||||
|
@@ -29,17 +29,20 @@ function init(_runtime) {
|
||||
}
|
||||
|
||||
function registerType(id,type) {
|
||||
if (knownTypes.hasOwnProperty(type)) {
|
||||
throw new Error(`Library type '${type}' already registerd by ${id}'`)
|
||||
}
|
||||
// TODO: would like to enforce this, but currently the tests register the same type multiple
|
||||
// times and have no way to remove themselves.
|
||||
// if (knownTypes.hasOwnProperty(type)) {
|
||||
// throw new Error(`Library type '${type}' already registered by ${id}'`)
|
||||
// }
|
||||
knownTypes[type] = id;
|
||||
}
|
||||
|
||||
function getAllEntries(type) {
|
||||
if (!knownTypes.hasOwnProperty(type)) {
|
||||
throw new Error(`Unknown library type '${type}'`);
|
||||
}
|
||||
}
|
||||
// function getAllEntries(type) {
|
||||
// if (!knownTypes.hasOwnProperty(type)) {
|
||||
// throw new Error(`Unknown library type '${type}'`);
|
||||
// }
|
||||
// }
|
||||
|
||||
function getEntry(type,path) {
|
||||
if (type !== 'flows') {
|
||||
if (!knownTypes.hasOwnProperty(type)) {
|
||||
@@ -67,12 +70,11 @@ function getEntry(type,path) {
|
||||
return reject(err);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// IF we get here, we didn't find the file
|
||||
var error = new Error("not_found");
|
||||
error.code = "not_found";
|
||||
return reject(error);
|
||||
}
|
||||
// IF we get here, we didn't find the file
|
||||
var error = new Error("not_found");
|
||||
error.code = "not_found";
|
||||
return reject(error);
|
||||
} else {
|
||||
resolve(storage.getFlow(path));
|
||||
}
|
||||
@@ -92,8 +94,8 @@ function saveEntry(type,path,meta,body) {
|
||||
|
||||
module.exports = {
|
||||
init: init,
|
||||
registerType: registerType,
|
||||
getAllEntries: getAllEntries,
|
||||
register: registerType,
|
||||
// getAllEntries: getAllEntries,
|
||||
getEntry: getEntry,
|
||||
saveEntry: saveEntry
|
||||
|
||||
|
@@ -79,6 +79,11 @@ function createNodeApi(node) {
|
||||
retain: retain
|
||||
})
|
||||
}
|
||||
},
|
||||
library: {
|
||||
register: function(type) {
|
||||
return runtime.library.register(node.id,type);
|
||||
}
|
||||
}
|
||||
}
|
||||
copyObjectProperties(runtime.nodes,red.nodes,["createNode","getNode","eachNode","addCredentials","getCredentials","deleteCredentials" ]);
|
||||
@@ -88,11 +93,6 @@ function createNodeApi(node) {
|
||||
copyObjectProperties(runtime.log,red.log,null,["init"]);
|
||||
copyObjectProperties(runtime.settings,red.settings,null,["init","load","reset"]);
|
||||
if (runtime.adminApi) {
|
||||
red.library = {
|
||||
register: function(type) {
|
||||
return runtime.library.registerType(node.id,type);
|
||||
}
|
||||
};
|
||||
red.auth = runtime.adminApi.auth;
|
||||
red.httpAdmin = runtime.adminApi.adminApp;
|
||||
red.httpNode = runtime.nodeApp;
|
||||
@@ -100,12 +100,6 @@ function createNodeApi(node) {
|
||||
} else {
|
||||
//TODO: runtime.adminApi is always stubbed if not enabled, so this block
|
||||
// is unused - but may be needed for the unit tests
|
||||
red.comms = {
|
||||
publish: function() {}
|
||||
};
|
||||
red.library = {
|
||||
register: function() {}
|
||||
};
|
||||
red.auth = {
|
||||
needsPermission: function() {}
|
||||
};
|
||||
|
Reference in New Issue
Block a user