mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
docs(guide/unit-testing): fix controller test example
This commit is contained in:
parent
dc238ce123
commit
c785b2edff
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue