试图了解茉莉花间谍,这就是我的测试的样子:
$scope.switchTurns = function () {
$scope.playerTurn = !$scope.playerTurn;
console.log($scope.centrePileCards.length);
if ($scope.playerTurn == 1) {
$scope.pickCard();
}
}
我的单元测试如下所示:
it('should pick one card',function(){
var controller = createController();
spyOn(scope,'pickCard')
scope.switchTurns();
scope.playerTurn=1;
expect(scope.pickCard()).toHaveBeenCalled();
})
我现在收到此错误:
Error : Expected a spy , but got undefined.
建议?