我的规格:
describe('ScheduleController', function() {
var ScheduleController, scope, spies = {};
beforeEach(function() {
module('mapApp');
return inject(function($injector) {
var $controller, $rootScope;
$rootScope = $injector.get('$rootScope');
$controller = $injector.get('$controller');
scope = $rootScope.$new()
$controller('ScheduleController', {
$scope: scope
});
spies.buildScheduleUrl = spyOn(scope, 'buildScheduleUrl').and.callThrough();
});
});
it('should build a schedule url', function() {
expect(spies.buildScheduleUrl).toHaveBeenCalled();
});
});
我的控制器:
window.map.controller('ScheduleController', ['$scope', '$window', 'cache', 'scheduleCache', 'dosingCache', 'patientCache', '$modal', 'util',
function ($scope, $window, cache, scheduleCache, dosingCache, patientCache, $modal, util) {
// other stuff here
$scope.buildScheduleUrl();
}
]);
所以我的buildScheduleUrl
函数似乎没有被调用。我究竟做错了什么?