1
0
Fork 0

fixed tests

This commit is contained in:
Frank Celler 2013-07-25 18:48:31 +02:00
parent 45aff333da
commit 62b61ab12a
2 changed files with 14 additions and 51 deletions

View File

@ -9,7 +9,7 @@ var jsunity = require("jsunity"),
function CreateFoxxApplicationSpec () {
return {
testCreationWithoutParameters: function () {
var app = new FoxxApplication(),
var app = new FoxxApplication({prefix: "", foxxes: []}),
routingInfo = app.routingInfo;
assertEqual(routingInfo.routes.length, 0);
@ -17,7 +17,7 @@ function CreateFoxxApplicationSpec () {
},
testCreationWithURLPrefix: function () {
var app = new FoxxApplication({urlPrefix: "/wiese"}),
var app = new FoxxApplication({prefix: "", foxxes: []}, {urlPrefix: "/wiese"}),
routingInfo = app.routingInfo;
assertEqual(routingInfo.routes.length, 0);
@ -28,7 +28,7 @@ function CreateFoxxApplicationSpec () {
var app, routingInfo, templateCollection;
db._drop("wiese");
app = new FoxxApplication({templateCollection: "wiese"});
app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"});
routingInfo = app.routingInfo;
templateCollection = db._collection("wiese");
@ -42,7 +42,7 @@ function CreateFoxxApplicationSpec () {
db._drop("wiese");
db._create("wiese");
app = new FoxxApplication({templateCollection: "wiese"});
app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"});
routingInfo = app.routingInfo;
templateCollection = db._collection("wiese");
@ -52,25 +52,12 @@ function CreateFoxxApplicationSpec () {
},
testAdditionOfBaseMiddlewareInRoutingInfo: function () {
var app = new FoxxApplication(),
var app = new FoxxApplication({prefix: "", foxxes: []}),
routingInfo = app.routingInfo,
hopefully_base = routingInfo.middleware[0];
assertEqual(routingInfo.middleware.length, 1);
assertEqual(hopefully_base.url.match, "/*");
},
testAdditionOfRepositoryInRoutingInfo: function () {
var app = new FoxxApplication(),
routingInfo = app.routingInfo;
app.registerRepository("todos", {
model: "models/todo",
repository: "repositories/todos"
});
assertEqual(routingInfo.repositories.todos.model, "models/todo");
assertEqual(routingInfo.repositories.todos.repository, "repositories/todos");
}
};
}
@ -80,7 +67,7 @@ function SetRoutesFoxxApplicationSpec () {
return {
setUp: function () {
app = new FoxxApplication();
app = new FoxxApplication({prefix: "", foxxes: []});
},
testSettingRoutes: function () {
@ -196,34 +183,6 @@ function SetRoutesFoxxApplicationSpec () {
}
assertEqual(error, "URL has to be a String");
assertEqual(routes.length, 0);
},
testSettingHandlers: function () {
var myFunc = function a (b, c) { return b + c;},
myFuncString = "function a(b, c) { return b + c;}",
routes = app.routingInfo.routes,
action;
app.get('/simple/route', myFunc);
action = routes[0].action;
assertEqual(routes.length, 1);
assertEqual(action.callback, myFuncString);
},
testStartAddsRequiresAndContext: function () {
var myFunc = function () {},
routingInfo = app.routingInfo,
context = {};
app.requires = {
a: 1
};
app.get('/simple/route', myFunc);
app.start(context);
assertEqual(context.requires.a, 1);
assertEqual(context.routingInfo, routingInfo);
}
};
}
@ -233,7 +192,7 @@ function DocumentationAndConstraintsSpec () {
return {
setUp: function () {
app = new FoxxApplication(),
app = new FoxxApplication({prefix: "", foxxes: []}),
routes = app.routingInfo.routes;
},
@ -403,7 +362,7 @@ function AddMiddlewareFoxxApplicationSpec () {
return {
setUp: function () {
app = new FoxxApplication();
app = new FoxxApplication({prefix: "", foxxes: []});
},
testAddABeforeMiddlewareForAllRoutes: function () {
@ -660,7 +619,7 @@ function ViewHelperSpec () {
return {
setUp: function () {
app = new FoxxApplication();
app = new FoxxApplication({prefix: "", foxxes: []});
Middleware = require('org/arangodb/foxx').BaseMiddleware;
request = {};
response = {};

View File

@ -116,7 +116,11 @@ Application = function (context, options) {
if (urlPrefix === "") {
urlPrefix = context.prefix;
} else {
urlPrefix = context.prefix + "/" + urlPrefix;
if (context.prefix === "") {
urlPrefix = urlPrefix;
} else {
urlPrefix = context.prefix + "/" + urlPrefix;
}
}
this.helperCollection = {};