aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/dev_guide.unit-testing.ngdoc
diff options
context:
space:
mode:
authorPete Bacon Darwin2013-06-04 22:10:04 +0100
committerPete Bacon Darwin2013-06-04 22:10:27 +0100
commitaa839b9ff0908b18ebd1cf898f4093da0e76d1f7 (patch)
tree4f034331d5fd2f7348e3c83383d8b3f871e7d6a6 /docs/content/guide/dev_guide.unit-testing.ngdoc
parentfdb66aa23722d0a758457ae57cfe700a88329093 (diff)
downloadangular.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.ngdoc9
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