mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
slightly enhance test coverage for info and log and settings.
This commit is contained in:
parent
234abd82a2
commit
082ce798d8
@ -26,6 +26,7 @@ var persistentSettings = {
|
|||||||
init: function(settings) {
|
init: function(settings) {
|
||||||
userSettings = settings;
|
userSettings = settings;
|
||||||
for (var i in settings) {
|
for (var i in settings) {
|
||||||
|
/* istanbul ignore else */
|
||||||
if (settings.hasOwnProperty(i)) {
|
if (settings.hasOwnProperty(i)) {
|
||||||
(function() {
|
(function() {
|
||||||
var j = i;
|
var j = i;
|
||||||
@ -51,7 +52,7 @@ var persistentSettings = {
|
|||||||
}
|
}
|
||||||
return clone(globalSettings[prop]);
|
return clone(globalSettings[prop]);
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(prop,value) {
|
set: function(prop,value) {
|
||||||
if (userSettings.hasOwnProperty(prop)) {
|
if (userSettings.hasOwnProperty(prop)) {
|
||||||
throw new Error("Property '"+prop+"' is read-only");
|
throw new Error("Property '"+prop+"' is read-only");
|
||||||
@ -68,13 +69,14 @@ var persistentSettings = {
|
|||||||
return storage.saveSettings(globalSettings);
|
return storage.saveSettings(globalSettings);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
available: function() {
|
available: function() {
|
||||||
return (globalSettings !== null);
|
return (globalSettings !== null);
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
for (var i in userSettings) {
|
for (var i in userSettings) {
|
||||||
|
/* istanbul ignore else */
|
||||||
if (userSettings.hasOwnProperty(i)) {
|
if (userSettings.hasOwnProperty(i)) {
|
||||||
delete persistentSettings[i];
|
delete persistentSettings[i];
|
||||||
}
|
}
|
||||||
|
@ -30,17 +30,18 @@ describe("info api", function() {
|
|||||||
var userSettings = {
|
var userSettings = {
|
||||||
foo: 123,
|
foo: 123,
|
||||||
httpNodeRoot: "testHttpNodeRoot",
|
httpNodeRoot: "testHttpNodeRoot",
|
||||||
version: "testVersion"
|
version: "testVersion",
|
||||||
|
paletteCategories :["red","blue","green"]
|
||||||
}
|
}
|
||||||
settings.init(userSettings);
|
settings.init(userSettings);
|
||||||
app = express();
|
app = express();
|
||||||
app.get("/settings",info.settings);
|
app.get("/settings",info.settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
settings.reset();
|
settings.reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the filtered settings', function(done) {
|
it('returns the filtered settings', function(done) {
|
||||||
request(app)
|
request(app)
|
||||||
.get("/settings")
|
.get("/settings")
|
||||||
|
@ -19,4 +19,21 @@ describe("red/log", function() {
|
|||||||
it('can be required without errors', function() {
|
it('can be required without errors', function() {
|
||||||
require("../../red/log");
|
require("../../red/log");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var log = require("../../red/log");
|
||||||
|
|
||||||
|
it('it can raise an error', function() {
|
||||||
|
var m = {level:20, msg:"This is an error", type:"test", id:"12345", name:"ERROR" };
|
||||||
|
var ret = log.error(m);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it can raise a trace', function() {
|
||||||
|
var m = {level:60, msg:"This is a trace", type:"test", id:"12345", name:"TRACE" };
|
||||||
|
var ret = log.trace(m);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it can raise a debug', function() {
|
||||||
|
var m = {level:50, msg:"This is a debug", type:"test", id:"12345", name:"DEBUG" };
|
||||||
|
var ret = log.debug(m);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user