From c785b2edff50e9d9b1874d03d2399509d1aa062e Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Tue, 4 Jun 2013 22:10:04 +0100 Subject: docs(guide/unit-testing): fix controller test example --- docs/content/guide/dev_guide.unit-testing.ngdoc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'docs/content/guide/dev_guide.unit-testing.ngdoc') 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
-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');
Notice that the test is not only much shorter but it is easier to follow what is going on. We say
--
cgit v1.2.3