aboutsummaryrefslogtreecommitdiffstats
path: root/docs/content/guide/dev_guide.unit-testing.ngdoc
diff options
context:
space:
mode:
authorSiddique Hameed2013-05-22 13:47:17 -0500
committerChirayu Krishnappa2013-05-23 21:55:44 -0700
commit4179f62cc270b9614075095e1e4931736cff30a7 (patch)
treeb39a645184c20b8869b1281666fb1be36dc42bed /docs/content/guide/dev_guide.unit-testing.ngdoc
parentf4c6b2c7894cb2d82ac69a1500a27785360b81c3 (diff)
downloadangular.js-4179f62cc270b9614075095e1e4931736cff30a7.tar.bz2
docs(guide/unit-testing): add expression example
* Improved developer guide, directive unit testing documentation code with scope expression * Removed documentation block with nothing on it
Diffstat (limited to 'docs/content/guide/dev_guide.unit-testing.ngdoc')
-rw-r--r--docs/content/guide/dev_guide.unit-testing.ngdoc26
1 files changed, 7 insertions, 19 deletions
diff --git a/docs/content/guide/dev_guide.unit-testing.ngdoc b/docs/content/guide/dev_guide.unit-testing.ngdoc
index 175af471..c27180fe 100644
--- a/docs/content/guide/dev_guide.unit-testing.ngdoc
+++ b/docs/content/guide/dev_guide.unit-testing.ngdoc
@@ -294,14 +294,14 @@ app.directive('aGreatEye', function () {
return {
restrict: 'E',
replace: true,
- template: '<h1>lidless, wreathed in flame</h1>'
+ template: '<h1>lidless, wreathed in flame, {{1 + 1}} times</h1>'
};
});
</pre>
This directive is used as a tag `<a-great-eye></a-great-eye>`. It replaces the entire tag with the
-template `<h1>lidless, wreathed in flame</h1>`. Now we are going to write a jasmine unit test to
-verify this functionality.
+template `<h1>lidless, wreathed in flame, {{1 + 1}} times</h1>`. Now we are going to write a jasmine unit test to
+verify this functionality. Note that the expression `{{1 + 1}}` times will also be evaluated in the rendered content.
<pre>
describe('Unit testing great quotes', function() {
@@ -322,30 +322,18 @@ describe('Unit testing great quotes', function() {
it('Replaces the element with the appropriate content', function() {
// Compile a piece of HTML containing the directive
var element = $compile("<a-great-eye></a-great-eye>")($rootScope);
+ // fire all the watches, so the scope expression {{1 + 1}} will be evaluated
+ $rootScope.$digest();
// Check that the compiled element contains the templated content
- expect(element.html()).toContain("lidless, wreathed in flame");
+ expect(element.html()).toContain("lidless, wreathed in flame, 2 times");
});
});
</pre>
We inject the $compile service and $rootScope before each jasmine test. The $compile service is used
to render the aGreatEye directive. After rendering the directive we ensure that the directive has
-replaced the content and "lidless, wreathed in flame" is present.
+replaced the content and "lidless, wreathed in flame, 2 times" is present.
-## Mocks
-oue
-
-## Global State Isolation
-oue
-
-# Preferred way of Testing
-uo
-
-## JavaScriptTestDriver
-ou
-
-## Jasmine
-ou
## Sample project
See the {@link https://github.com/angular/angular-seed angular-seed} project for an example.