Disable palette editor if npm not found

This commit is contained in:
Nick O'Leary
2016-10-12 22:30:32 +01:00
parent a76674032d
commit 49f72881f4
11 changed files with 108 additions and 30 deletions

View File

@@ -30,7 +30,9 @@ describe("api index", function() {
before(function() {
api.init({},{
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:true},
events: {on:function(){},removeListener: function(){}}
events: {on:function(){},removeListener: function(){}},
log: {info:function(){},_:function(){}},
nodes: {paletteEditorEnabled: function(){return true}}
});
app = api.adminApp;
});

View File

@@ -28,14 +28,6 @@ describe("info api", function() {
describe("settings handler", function() {
before(function() {
sinon.stub(theme,"settings",function() { return { test: 456 };});
info.init({
settings: {
foo: 123,
httpNodeRoot: "testHttpNodeRoot",
version: "testVersion",
paletteCategories :["red","blue","green"]
}
})
app = express();
app.get("/settings",info.settings);
});
@@ -45,6 +37,17 @@ describe("info api", function() {
});
it('returns the filtered settings', function(done) {
info.init({
settings: {
foo: 123,
httpNodeRoot: "testHttpNodeRoot",
version: "testVersion",
paletteCategories :["red","blue","green"]
},
nodes: {
paletteEditorEnabled: function() { return true; }
}
});
request(app)
.get("/settings")
.expect(200)
@@ -60,6 +63,35 @@ describe("info api", function() {
done();
});
});
it('overrides palette editable if runtime says it is disabled', function(done) {
info.init({
settings: {
httpNodeRoot: "testHttpNodeRoot",
version: "testVersion",
paletteCategories :["red","blue","green"]
},
nodes: {
paletteEditorEnabled: function() { return false; }
}
});
request(app)
.get("/settings")
.expect(200)
.end(function(err,res) {
if (err) {
return done(err);
}
res.body.should.have.property("httpNodeRoot","testHttpNodeRoot");
res.body.should.have.property("version","testVersion");
res.body.should.have.property("paletteCategories",["red","blue","green"]);
res.body.should.have.property("editorTheme");
res.body.editorTheme.should.have.property("test",456);
res.body.editorTheme.should.have.property("palette",{editable:false});
done();
});
})
});
});