0

I have this code

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 gets assigned when the controller loads. I'm trying to spy on it, so I am creating an empty function first. When the test runs I get: Expected a spy, but got Function.

How can I check $scope.checkConnectionToRoom gets called?

Si-N
  • 1,495
  • 1
  • 13
  • 27

0 Answers0