mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
revert/redo tests for api/index, log and Node_spec
This commit is contained in:
parent
ff093d98c6
commit
10277aa956
@ -27,7 +27,7 @@ describe("api index", function() {
|
||||
|
||||
describe("disables editor", function() {
|
||||
before(function() {
|
||||
settings.init({disableEditor:true,adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}});
|
||||
settings.init({disableEditor:true});
|
||||
app = express();
|
||||
api.init(app);
|
||||
});
|
||||
@ -50,6 +50,34 @@ describe("api index", function() {
|
||||
.get("/settings")
|
||||
.expect(200,done)
|
||||
});
|
||||
it('does not serve auth', function(done) {
|
||||
request(app)
|
||||
.get("/auth/login")
|
||||
.expect(404,done)
|
||||
});
|
||||
});
|
||||
|
||||
describe("can serve auth", function() {
|
||||
before(function() {
|
||||
//settings.init({disableEditor:true});
|
||||
settings.init({adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}});
|
||||
app = express();
|
||||
api.init(app);
|
||||
});
|
||||
after(function() {
|
||||
settings.reset();
|
||||
});
|
||||
|
||||
it('it now serves auth', function(done) {
|
||||
request(app)
|
||||
.get("/auth/login")
|
||||
.expect(200)
|
||||
.end(function(err,res) {
|
||||
if (err) { return done(err); }
|
||||
res.body.type.should.equal("credentials");
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("enables editor", function() {
|
||||
|
@ -49,10 +49,14 @@ describe("red/log", function() {
|
||||
sinon.assert.calledWithMatch(util.log,"");
|
||||
});
|
||||
|
||||
it('it checks level of metrics', function() {
|
||||
it('it checks metrics are enabled', function() {
|
||||
log.metric().should.equal(true);
|
||||
var sett = {logging: { console: { level: 'info', metrics: false } } };
|
||||
log.init(sett);
|
||||
});
|
||||
|
||||
it('it checks metrics are disabled', function() {
|
||||
log.metric().should.equal(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -404,7 +404,7 @@ describe('Node', function() {
|
||||
});
|
||||
|
||||
describe('#error', function() {
|
||||
it('produces an error message', function(done) {
|
||||
it('handles a null error message', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var loginfo = {};
|
||||
sinon.stub(Log, 'log', function(msg) {
|
||||
@ -427,6 +427,31 @@ describe('Node', function() {
|
||||
flows.handleError.restore();
|
||||
done();
|
||||
});
|
||||
|
||||
it('produces an error message', function(done) {
|
||||
var n = new RedNode({id:'123',type:'abc'});
|
||||
var loginfo = {};
|
||||
sinon.stub(Log, 'log', function(msg) {
|
||||
loginfo = msg;
|
||||
});
|
||||
sinon.stub(flows,"handleError", function(node,message,msg) {
|
||||
});
|
||||
|
||||
var message = {a:2};
|
||||
|
||||
n.error("This is an error",message);
|
||||
should.deepEqual({level:Log.ERROR, id:n.id, type:n.type, msg:"This is an error"}, loginfo);
|
||||
|
||||
flows.handleError.called.should.be.true;
|
||||
flows.handleError.args[0][0].should.eql(n);
|
||||
flows.handleError.args[0][1].should.eql("This is an error");
|
||||
flows.handleError.args[0][2].should.eql(message);
|
||||
|
||||
Log.log.restore();
|
||||
flows.handleError.restore();
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#metric', function() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user