我正在尝试验证我添加的路由是否存在但是我在这里得到一个未定义的函数错误:routerUtil.setRoutes();
我还观察到我在路由器koaRouter.get上的routerUtil.js中出现语法错误,因为它无法识别get。
routerUtil.js
'use strict';
var koaRouter = require('koa-router')();
var router = module.exports = {
router: koaRouter,
setRoutes: setRoutes()
};
function setRoutes()
{
koaRouter.get('default', '/', function *(next){
});
}
myBddTest.js
var routerUtil = require('../../../routes/routerUtil');
var should = require('chai').should();
var koa = require('koa')();
describe('Feature: GET SomeResource REST Endpoint', function () {
context('Scenario: No Results Exist - SomeResource', function () {
var uri = '/SomeResource';
describe('Given: There is a REST endpoint for this SomeResource', function () {
// PASSES
it('should have a router available', function(done){
routerUtil.router.should.be.a('object');
done();
});
// FAILS
it('should have a default endpoint', function(){
routerUtil.setRoutes();
routerUtil.router.routes.name('default').should.exist;
});