我有这段代码
it('should call checkConnectionToRoom when controller loads', function(done) {
$scope.checkConnectionToRoom = function() {};
spyOn($scope, 'checkConnectionToRoom').and.callThrough();
roomController = $controller('RoomController', {$scope: $scope});
expect($scope.checkConnectionToRoom).toHaveBeenCalledTimes(1);
done();
});
控制器加载时会分配 $scope.checkConnectionToRoom
。我正在试图窥探它,所以我先创建一个空函数。测试运行时,我得到:Expected a spy, but got Function.
如何查看$scope.checkConnectionToRoom
被叫?