Update tests for runtime/api separation

This commit is contained in:
Nick O'Leary
2015-11-12 07:56:23 +00:00
parent f43738446e
commit 9f5e6a4b37
53 changed files with 246 additions and 284 deletions

View File

@@ -28,13 +28,11 @@ describe("api index", function() {
describe("disables editor", function() {
before(function() {
app = express();
api.init(app,{
settings:{disableEditor:true},
api:{
}
api.init({
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:true},
events: {on:function(){},removeListener: function(){}}
});
app = api.adminApp();
});
it('does not serve the editor', function(done) {
@@ -69,11 +67,11 @@ describe("api index", function() {
})
});
before(function() {
app = express();
api.init(app,{
settings:{adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
api.init({
settings:{httpNodeRoot:true, httpAdminRoot: true, adminAuth:{type: "credentials",users:[],default:{permissions:"read"}}},
storage:{getSessions:function(){return when.resolve({})}}
});
app = api.adminApp();
});
it('it now serves auth', function(done) {
@@ -105,12 +103,12 @@ describe("api index", function() {
});
before(function() {
app = express();
api.init(app,{
api.init({
log:{audit:function(){}},
settings:{disableEditor:false},
settings:{httpNodeRoot:true, httpAdminRoot: true,disableEditor:false},
events:{on:function(){},removeListener:function(){}}
});
app = api.adminApp();
});
it('serves the editor', function(done) {
request(app)

View File

@@ -21,8 +21,6 @@ var bodyParser = require('body-parser');
var sinon = require('sinon');
var when = require('when');
var settings = require("../../../red/settings");
var nodes = require("../../../red/api/nodes");
describe("nodes api", function() {
@@ -335,9 +333,6 @@ describe("nodes api", function() {
});
describe('delete', function() {
it('returns 400 if settings are unavailable', function(done) {
var settingsAvailable = sinon.stub(settings,'available', function() {
return false;
});
initNodes({
settings:{available:function(){return false}}
});
@@ -346,7 +341,6 @@ describe("nodes api", function() {
.del('/nodes/123')
.expect(400)
.end(function(err,res) {
settingsAvailable.restore();
if (err) {
throw err;
}

View File

@@ -22,7 +22,6 @@ var when = require('when');
var fs = require("fs");
var app = express();
var settings = require("../../../red/settings");
var theme = require("../../../red/api/theme");