@@ -180,9 +180,9 @@ Notice that no global variables were harmed in the writing of this test.
180
180
Angular comes with {@link di dependency injection} built-in, making the right thing
181
181
easy to do, but you still need to do it if you wish to take advantage of the testability story.
182
182
183
- ## Additional libraries for testing Angular applications
183
+ ## Additional tools for testing Angular applications
184
184
185
- For testing Angular applications there are libraries that you should use that will make testing much
185
+ For testing Angular applications there are certain tools that you should use that will make testing much
186
186
easier to set up and run.
187
187
188
188
### Karma
@@ -198,7 +198,7 @@ are available on [the Karma website](http://karma-runner.github.io/0.12/intro/in
198
198
199
199
### Jasmine
200
200
201
- [Jasmine](http://jasmine.github.io/2.0 /introduction.html) is a test driven development framework for
201
+ [Jasmine](http://jasmine.github.io/1.3 /introduction.html) is a test driven development framework for
202
202
JavaScript that has become the most popular choice for testing Angular applications. Jasmine
203
203
provides functions to help with structuring your tests and also making assertions. As your tests
204
204
grow, keeping them well structured and documented is vital, and Jasmine helps achieve this.
@@ -214,20 +214,21 @@ describe("sorting the list of users", function() {
214
214
And then each individual test is defined within a call to the `it` function:
215
215
216
216
```js
217
- describe(" sorting the list of users" , function() {
218
- it(" sorts in descending order by default" , function() {
217
+ describe(' sorting the list of users' , function() {
218
+ it(' sorts in descending order by default' , function() {
219
219
// your test assertion goes here
220
220
});
221
221
});
222
222
```
223
223
224
- By grouping related tests within `describe` blocks, and describing each individual test within an
225
- `it` call, this keeps your tests self documented. Finally, Jasmine provides matchers which let you
226
- make assertions:
224
+ Grouping related tests within `describe` blocks and describing each individual test within an
225
+ `it` call keeps your tests self documenting.
226
+
227
+ Finally, Jasmine provides matchers which let you make assertions:
227
228
228
229
```js
229
- describe(" sorting the list of users" , function() {
230
- it(" sorts in descending order by default" , function() {
230
+ describe(' sorting the list of users' , function() {
231
+ it(' sorts in descending order by default' , function() {
231
232
var users = ['jack', 'igor', 'jeff'];
232
233
var sorted = sortUsers(users);
233
234
expect(sorted).toEqual(['jeff', 'jack', 'igor']);
@@ -236,8 +237,9 @@ describe("sorting the list of users", function() {
236
237
```
237
238
238
239
Jasmine comes with a number of matchers that help you make a variety of assertions. You should [read
239
- the Jasmine documentation](http://jasmine.github.io/2.0/introduction.html#section-Matchers) to see
240
- what they are.
240
+ the Jasmine documentation](http://jasmine.github.io/1.3/introduction.html#section-Matchers) to see
241
+ what they are. To use Jasmine with Karma, we use the
242
+ [karma-jasmine](https://github.com/karma-runner/karma-jasmine) test runner.
241
243
242
244
### angular-mocks
243
245
@@ -254,8 +256,7 @@ look at how we might test the controller below, which provides `$scope.grade`, w
254
256
on the scope based on the length of the password.
255
257
256
258
```js
257
- angular
258
- .module('app')
259
+ angular.module('app', [])
259
260
.controller('PasswordController', function PasswordController($scope) {
260
261
$scope.password = '';
261
262
$scope.grade = function() {
@@ -380,7 +381,7 @@ The duplication is now gone, and encapsulated within the `beforeEach`. Each indi
380
381
contains the code specific to that test, and not code that is general across all tests. As you
381
382
expand your tests, keep an eye out for locations where you can use `beforeEach` to tidy up tests.
382
383
`beforeEach` isn't the only function of this sort that Jasmine provides, and the [documentation
383
- lists the others](http://jasmine.github.io/2.0 /introduction.html#section-Setup_and_Teardown).
384
+ lists the others](http://jasmine.github.io/1.3 /introduction.html#section-Setup_and_Teardown).
384
385
385
386
## Testing Filters
386
387
{@link ng.$filterProvider Filters} are functions which transform the data into a user readable
0 commit comments