@@ -294,14 +294,14 @@ app.directive('aGreatEye', function () {
294
294
return {
295
295
restrict: 'E',
296
296
replace: true,
297
- template: '<h1>lidless, wreathed in flame</h1>'
297
+ template: '<h1>lidless, wreathed in flame, {{1 + 1}} times </h1>'
298
298
};
299
299
});
300
300
</pre>
301
301
302
302
This directive is used as a tag `<a-great-eye></a-great-eye>`. It replaces the entire tag with the
303
- template `<h1>lidless, wreathed in flame</h1>`. Now we are going to write a jasmine unit test to
304
- verify this functionality.
303
+ template `<h1>lidless, wreathed in flame, {{1 + 1}} times </h1>`. Now we are going to write a jasmine unit test to
304
+ verify this functionality. Note that the expression `{{1 + 1}}` times will also be evaluated in the rendered content.
305
305
306
306
<pre>
307
307
describe('Unit testing great quotes', function() {
@@ -322,30 +322,18 @@ describe('Unit testing great quotes', function() {
322
322
it('Replaces the element with the appropriate content', function() {
323
323
// Compile a piece of HTML containing the directive
324
324
var element = $compile("<a-great-eye></a-great-eye>")($rootScope);
325
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
326
+ $rootScope.$digest();
325
327
// Check that the compiled element contains the templated content
326
- expect(element.html()).toContain("lidless, wreathed in flame");
328
+ expect(element.html()).toContain("lidless, wreathed in flame, 2 times ");
327
329
});
328
330
});
329
331
</pre>
330
332
331
333
We inject the $compile service and $rootScope before each jasmine test. The $compile service is used
332
334
to render the aGreatEye directive. After rendering the directive we ensure that the directive has
333
- replaced the content and "lidless, wreathed in flame" is present.
335
+ replaced the content and "lidless, wreathed in flame, 2 times " is present.
334
336
335
- ## Mocks
336
- oue
337
-
338
- ## Global State Isolation
339
- oue
340
-
341
- # Preferred way of Testing
342
- uo
343
-
344
- ## JavaScriptTestDriver
345
- ou
346
-
347
- ## Jasmine
348
- ou
349
337
350
338
## Sample project
351
339
See the {@link https://github.com/angular/angular-seed angular-seed} project for an example.
0 commit comments