Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c785b2e

Browse files
docs(guide/unit-testing): fix controller test example
1 parent dc238ce commit c785b2e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/content/guide/dev_guide.unit-testing.ngdoc

+5-4
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,11 @@ function PasswordCtrl($scope) {
248248
and the test is straight forward
249249

250250
<pre>
251-
var pc = new PasswordCtrl();
252-
pc.password('abc');
253-
pc.grade();
254-
expect(pc.strength).toEqual('weak');
251+
var $scope = {};
252+
var pc = $controller('PasswordCtrl', { $scope: $scope });
253+
$scope.password = 'abc';
254+
$scope.grade();
255+
expect($scope.strength).toEqual('weak');
255256
</pre>
256257

257258
Notice that the test is not only much shorter but it is easier to follow what is going on. We say

0 commit comments

Comments
 (0)