试图让我的头围绕茉莉花间谍,这就是我的测试:
$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.
建议?
答案 0 :(得分:21)
=IIF(Parameters!IsSummary.Value, "Report (Summary)", "Report (Detail)")
是方法的结果。在您的情况下,它是scope.pickCard()
。
当您使用undefined
时,您应该写:
spyOn