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:04 +0100
commitc785b2edff50e9d9b1874d03d2399509d1aa062e (patch)
tree6ba33e13f5442b957657fb2d196ffe88c9753412 /docs/content/guide/dev_guide.unit-testing.ngdoc
parentdc238ce123d6f4357878d0e6e58c8e2343337e26 (diff)
downloadangular.js-c785b2edff50e9d9b1874d03d2399509d1aa062e.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 c27180fe..e6bf7aa4 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