@@ -13,7 +13,7 @@ in the right order. In order to answer such question it is very important that w
13
13
That is because when we are testing the sort function we don't want to be forced into crating
14
14
related pieces such as the DOM elements, or making any XHR calls in getting the data to sort. While
15
15
this 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
17
17
piece of code which does everything. It reads the data from XHR, it sorts it and then it
18
18
manipulates the DOM. With angular we try to make it easy for you to do the right thing, and so we
19
19
provide 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
173
173
below:
174
174
175
175
<pre>
176
- function PasswordController () {
176
+ function PasswordCtrl () {
177
177
// get references to DOM elements
178
178
var msg = $('.ex1 span');
179
179
var input = $('.ex1 input');
@@ -207,7 +207,7 @@ $('body').html('<div class="ex1">')
207
207
.find('div')
208
208
.append(input)
209
209
.append(span);
210
- var pc = new PasswordController ();
210
+ var pc = new PasswordCtrl ();
211
211
input.val('abc');
212
212
pc.grade();
213
213
expect(span.text()).toEqual('weak');
@@ -218,7 +218,7 @@ In angular the controllers are strictly separated from the DOM manipulation logi
218
218
a much easier testability story as can be seen in this example:
219
219
220
220
<pre>
221
- function PasswordCntrl ($scope) {
221
+ function PasswordCtrl ($scope) {
222
222
$scope.password = '';
223
223
$scope.grade = function() {
224
224
var size = $scope.password.length;
@@ -236,7 +236,7 @@ function PasswordCntrl($scope) {
236
236
and the tests is straight forward
237
237
238
238
<pre>
239
- var pc = new PasswordController ();
239
+ var pc = new PasswordCtrl ();
240
240
pc.password('abc');
241
241
pc.grade();
242
242
expect(span.strength).toEqual('weak');
0 commit comments