diff options
| author | Pete Bacon Darwin | 2013-06-04 22:10:04 +0100 |
|---|---|---|
| committer | Pete Bacon Darwin | 2013-06-04 22:10:27 +0100 |
| commit | aa839b9ff0908b18ebd1cf898f4093da0e76d1f7 (patch) | |
| tree | 4f034331d5fd2f7348e3c83383d8b3f871e7d6a6 /docs/content/guide/dev_guide.unit-testing.ngdoc | |
| parent | fdb66aa23722d0a758457ae57cfe700a88329093 (diff) | |
| download | angular.js-aa839b9ff0908b18ebd1cf898f4093da0e76d1f7.tar.bz2 | |
docs(guide/unit-testing): fix controller test example
Diffstat (limited to 'docs/content/guide/dev_guide.unit-testing.ngdoc')
| -rw-r--r-- | docs/content/guide/dev_guide.unit-testing.ngdoc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/docs/content/guide/dev_guide.unit-testing.ngdoc b/docs/content/guide/dev_guide.unit-testing.ngdoc index 175af471..723b1edf 100644 --- a/docs/content/guide/dev_guide.unit-testing.ngdoc +++ b/docs/content/guide/dev_guide.unit-testing.ngdoc @@ -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 |
