1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00
node-red/test/red/api/info_spec.js

70 lines
2.3 KiB
JavaScript
Raw Normal View History

2014-11-06 23:59:48 +01:00
/**
2015-04-13 23:15:15 +02:00
* Copyright 2014, 2015 IBM Corp.
2014-11-06 23:59:48 +01:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
var should = require("should");
var request = require('supertest');
var express = require('express');
var sinon = require('sinon');
var when = require('when');
var app = express();
var settings = require("../../../red/settings");
var info = require("../../../red/api/info");
2015-04-13 23:15:15 +02:00
var theme = require("../../../red/api/theme");
2014-11-06 23:59:48 +01:00
describe("info api", function() {
describe("settings handler", function() {
before(function() {
var userSettings = {
foo: 123,
httpNodeRoot: "testHttpNodeRoot",
version: "testVersion",
paletteCategories :["red","blue","green"]
2014-11-06 23:59:48 +01:00
}
settings.init(userSettings);
2015-04-13 23:15:15 +02:00
sinon.stub(theme,"settings",function() { return { test: 456 };});
2014-11-06 23:59:48 +01:00
app = express();
app.get("/settings",info.settings);
});
2014-11-06 23:59:48 +01:00
after(function() {
settings.reset();
2015-04-13 23:15:15 +02:00
theme.settings.restore();
2014-11-06 23:59:48 +01:00
});
2014-11-06 23:59:48 +01:00
it('returns the filtered settings', function(done) {
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"]);
2015-04-13 23:15:15 +02:00
res.body.should.have.property("editorTheme",{test:456});
2014-11-06 23:59:48 +01:00
res.body.should.not.have.property("foo",123);
done();
});
});
});
});