角度/茉莉花 - 监视范围功能

时间:2017-07-31 16:50:48

标签: angularjs jasmine

我有这段代码

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被叫?

0 个答案:

没有答案