docs(guide/unit-testing): fix controller test example

This commit is contained in:
Pete Bacon Darwin 2013-06-04 22:10:04 +01:00
parent dc238ce123
commit c785b2edff

View file

@ -248,10 +248,11 @@ function PasswordCtrl($scope) {
and the test is straight forward
<pre>
var pc = new PasswordCtrl();
pc.password('abc');
pc.grade();
expect(pc.strength).toEqual('weak');
var $scope = {};
var pc = $controller('PasswordCtrl', { $scope: $scope });
$scope.password = 'abc';
$scope.grade();
expect($scope.strength).toEqual('weak');
</pre>
Notice that the test is not only much shorter but it is easier to follow what is going on. We say