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