From fe6247a7f831f6f3ad873b31f2ac282b2762243d Mon Sep 17 00:00:00 2001 From: Siddique Hameed Date: Wed, 22 May 2013 13:47:17 -0500 Subject: 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 --- docs/content/guide/dev_guide.unit-testing.ngdoc | 26 +++++++------------------ 1 file 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 a25103b4..f029e6da 100644 --- a/docs/content/guide/dev_guide.unit-testing.ngdoc +++ b/docs/content/guide/dev_guide.unit-testing.ngdoc @@ -295,14 +295,14 @@ app.directive('aGreatEye', function () { return { restrict: 'E', replace: true, - template: '
describe('Unit testing great quotes', function() {
@@ -323,30 +323,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(" ")($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");
});
});
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.
--
cgit v1.2.3