我有一些网址,我试图针对我的路由器进行测试,所有这些网址在我介绍查询参数之前似乎都能正常工作。
'use strict';
describe('Routing: ', function () {
var location, route, rootScope, httpBackend;
beforeEach(module('moneyAngularApp'));
beforeEach(module('ngMockE2E'))
beforeEach(inject(
function( _$location_, _$route_, _$rootScope_, _$httpBackend_) {
location = _$location_;
route = _$route_;
rootScope = _$rootScope_;
httpBackend = _$httpBackend_;
}));
beforeEach(function(){
httpBackend.whenGET('/').respond(200)
/** None of these seem to work **/
httpBackend.whenGET(/\/quote\/quote.html\?symb=[a-zA-Z0-9]{1,}/).respond(200)
httpBackend.whenGET('/quote/quote.html?symb=FB').respond(200)
httpBackend.whenGET(/^quote\/quote.html/).respond(200)
})
describe('Stock Details: ', function(){
it('should load the stockDetails page with /quote/quote.html?symb=FB ', function(){
location.path('/quote/quote.html?symb=FB', true);
rootScope.$digest();
expect(route.current.controller).toBe('StockDetailsCtrl')
})
})
})
然后我运行grunt test
错误告诉我route.current未定义:
Chrome 36.0.1985 (Mac OS X 10.9.3) Routing: Stock Details: should load the stockDetails page with /quote/quote.html?symb=FB FAILED
TypeError: Cannot read property 'controller' of undefined
我认为我的httpBackend.whenGET()调用有问题,但不是100%肯定。有什么想法吗?
其他信息 - 这应该映射到:
.when('/quote/quote.html?', {
controller: 'StockDetailsCtrl',
templateUrl: 'views/stockdetails.html',
animate:'slideUp'
})