mirror of https://gitee.com/bigwinds/arangodb
fixed tests
This commit is contained in:
parent
45aff333da
commit
62b61ab12a
|
@ -9,7 +9,7 @@ var jsunity = require("jsunity"),
|
||||||
function CreateFoxxApplicationSpec () {
|
function CreateFoxxApplicationSpec () {
|
||||||
return {
|
return {
|
||||||
testCreationWithoutParameters: function () {
|
testCreationWithoutParameters: function () {
|
||||||
var app = new FoxxApplication(),
|
var app = new FoxxApplication({prefix: "", foxxes: []}),
|
||||||
routingInfo = app.routingInfo;
|
routingInfo = app.routingInfo;
|
||||||
|
|
||||||
assertEqual(routingInfo.routes.length, 0);
|
assertEqual(routingInfo.routes.length, 0);
|
||||||
|
@ -17,7 +17,7 @@ function CreateFoxxApplicationSpec () {
|
||||||
},
|
},
|
||||||
|
|
||||||
testCreationWithURLPrefix: function () {
|
testCreationWithURLPrefix: function () {
|
||||||
var app = new FoxxApplication({urlPrefix: "/wiese"}),
|
var app = new FoxxApplication({prefix: "", foxxes: []}, {urlPrefix: "/wiese"}),
|
||||||
routingInfo = app.routingInfo;
|
routingInfo = app.routingInfo;
|
||||||
|
|
||||||
assertEqual(routingInfo.routes.length, 0);
|
assertEqual(routingInfo.routes.length, 0);
|
||||||
|
@ -28,7 +28,7 @@ function CreateFoxxApplicationSpec () {
|
||||||
var app, routingInfo, templateCollection;
|
var app, routingInfo, templateCollection;
|
||||||
|
|
||||||
db._drop("wiese");
|
db._drop("wiese");
|
||||||
app = new FoxxApplication({templateCollection: "wiese"});
|
app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"});
|
||||||
routingInfo = app.routingInfo;
|
routingInfo = app.routingInfo;
|
||||||
templateCollection = db._collection("wiese");
|
templateCollection = db._collection("wiese");
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ function CreateFoxxApplicationSpec () {
|
||||||
|
|
||||||
db._drop("wiese");
|
db._drop("wiese");
|
||||||
db._create("wiese");
|
db._create("wiese");
|
||||||
app = new FoxxApplication({templateCollection: "wiese"});
|
app = new FoxxApplication({prefix: "", foxxes: []}, {templateCollection: "wiese"});
|
||||||
routingInfo = app.routingInfo;
|
routingInfo = app.routingInfo;
|
||||||
templateCollection = db._collection("wiese");
|
templateCollection = db._collection("wiese");
|
||||||
|
|
||||||
|
@ -52,25 +52,12 @@ function CreateFoxxApplicationSpec () {
|
||||||
},
|
},
|
||||||
|
|
||||||
testAdditionOfBaseMiddlewareInRoutingInfo: function () {
|
testAdditionOfBaseMiddlewareInRoutingInfo: function () {
|
||||||
var app = new FoxxApplication(),
|
var app = new FoxxApplication({prefix: "", foxxes: []}),
|
||||||
routingInfo = app.routingInfo,
|
routingInfo = app.routingInfo,
|
||||||
hopefully_base = routingInfo.middleware[0];
|
hopefully_base = routingInfo.middleware[0];
|
||||||
|
|
||||||
assertEqual(routingInfo.middleware.length, 1);
|
assertEqual(routingInfo.middleware.length, 1);
|
||||||
assertEqual(hopefully_base.url.match, "/*");
|
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 {
|
return {
|
||||||
setUp: function () {
|
setUp: function () {
|
||||||
app = new FoxxApplication();
|
app = new FoxxApplication({prefix: "", foxxes: []});
|
||||||
},
|
},
|
||||||
|
|
||||||
testSettingRoutes: function () {
|
testSettingRoutes: function () {
|
||||||
|
@ -196,34 +183,6 @@ function SetRoutesFoxxApplicationSpec () {
|
||||||
}
|
}
|
||||||
assertEqual(error, "URL has to be a String");
|
assertEqual(error, "URL has to be a String");
|
||||||
assertEqual(routes.length, 0);
|
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 {
|
return {
|
||||||
setUp: function () {
|
setUp: function () {
|
||||||
app = new FoxxApplication(),
|
app = new FoxxApplication({prefix: "", foxxes: []}),
|
||||||
routes = app.routingInfo.routes;
|
routes = app.routingInfo.routes;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -403,7 +362,7 @@ function AddMiddlewareFoxxApplicationSpec () {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setUp: function () {
|
setUp: function () {
|
||||||
app = new FoxxApplication();
|
app = new FoxxApplication({prefix: "", foxxes: []});
|
||||||
},
|
},
|
||||||
|
|
||||||
testAddABeforeMiddlewareForAllRoutes: function () {
|
testAddABeforeMiddlewareForAllRoutes: function () {
|
||||||
|
@ -660,7 +619,7 @@ function ViewHelperSpec () {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
setUp: function () {
|
setUp: function () {
|
||||||
app = new FoxxApplication();
|
app = new FoxxApplication({prefix: "", foxxes: []});
|
||||||
Middleware = require('org/arangodb/foxx').BaseMiddleware;
|
Middleware = require('org/arangodb/foxx').BaseMiddleware;
|
||||||
request = {};
|
request = {};
|
||||||
response = {};
|
response = {};
|
||||||
|
|
|
@ -116,7 +116,11 @@ Application = function (context, options) {
|
||||||
if (urlPrefix === "") {
|
if (urlPrefix === "") {
|
||||||
urlPrefix = context.prefix;
|
urlPrefix = context.prefix;
|
||||||
} else {
|
} else {
|
||||||
urlPrefix = context.prefix + "/" + urlPrefix;
|
if (context.prefix === "") {
|
||||||
|
urlPrefix = urlPrefix;
|
||||||
|
} else {
|
||||||
|
urlPrefix = context.prefix + "/" + urlPrefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.helperCollection = {};
|
this.helperCollection = {};
|
||||||
|
|
Loading…
Reference in New Issue