Is it possible at all?
I am creating controller and starting listening ready event by $scope.on('ready', ...);. Then I write in unit-test: $scope.$digest(); and 1 digest loop had been performed.
But, ready event will be broadcasted after "some" $digest loops, right? Maybe 10, maybe 100, maybe 100500 $digest loops could be performed before $scope ready.
So how I can do this? And do I need doing this?
For example, I can use this construction:
$scope.fooToBeCalledAfterReady = function () {
};
$scope.onReadyHandler = function () {
$scope.fooToBeCalledAfterReady();
};
$scope.on('ready', $scope.onReadyHandler);
And in unit test I will just write:
it('onReadyHandler test', function () {
spyOn($scope, 'fooToBeCalledAfterReady');
$scope.onReadyHandler();
expect($scope.fooToBeCalledAfterReady).toHaveBeenCalled();
});
Should I seek for some another way to test on scope ready?
Aucun commentaire:
Enregistrer un commentaire