@@ -13,7 +13,7 @@ in the right order. In order to answer such question it is very important that w
1313That is because when we are testing the sort function we don't want to be forced into crating
1414related pieces such as the DOM elements, or making any XHR calls in getting the data to sort. While
1515this may seem obvious it usually is very difficult to be able to call an individual function on a
16- typical project. The reason is that the developers often time mix concerns, and they end up with a
16+ typical project. The reason is that the developers often mix concerns, and they end up with a
1717piece of code which does everything. It reads the data from XHR, it sorts it and then it
1818manipulates the DOM. With angular we try to make it easy for you to do the right thing, and so we
1919provide dependency injection for your XHR (which you can mock out) and we created abstraction which
@@ -173,7 +173,7 @@ for your application is mixed in with DOM manipulation, it will be hard to test
173173below:
174174
175175<pre>
176- function PasswordController () {
176+ function PasswordCtrl () {
177177 // get references to DOM elements
178178 var msg = $('.ex1 span');
179179 var input = $('.ex1 input');
@@ -207,7 +207,7 @@ $('body').html('<div class="ex1">')
207207 .find('div')
208208 .append(input)
209209 .append(span);
210- var pc = new PasswordController ();
210+ var pc = new PasswordCtrl ();
211211input.val('abc');
212212pc.grade();
213213expect(span.text()).toEqual('weak');
@@ -218,7 +218,7 @@ In angular the controllers are strictly separated from the DOM manipulation logi
218218a much easier testability story as can be seen in this example:
219219
220220<pre>
221- function PasswordCntrl ($scope) {
221+ function PasswordCtrl ($scope) {
222222 $scope.password = '';
223223 $scope.grade = function() {
224224 var size = $scope.password.length;
@@ -236,7 +236,7 @@ function PasswordCntrl($scope) {
236236and the tests is straight forward
237237
238238<pre>
239- var pc = new PasswordController ();
239+ var pc = new PasswordCtrl ();
240240pc.password('abc');
241241pc.grade();
242242expect(span.strength).toEqual('weak');
0 commit comments