From 577351ecd7efe3207619dcbbd0a21d1f8b113932 Mon Sep 17 00:00:00 2001 From: JasonM23 Date: Fri, 16 Aug 2013 20:04:55 +1000 Subject: [PATCH] Added documentation for inject, summarising the _name_ syntax sugar on module parameter resolution. Added a summary describing the ignored underscore syntax helper, with a possible use case example. --- src/ngMock/angular-mocks.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 125a42a65c16..e86466026472 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1881,7 +1881,25 @@ angular.mock.clearDataCache = function() { * The inject function wraps a function into an injectable function. The inject() creates new * instance of {@link AUTO.$injector $injector} per test, which is then used for * resolving references. - * + * + * The injected references can optionally be named with enclosing underscores, which are ignored by + * the injector when the reference name is resolved. + * + * For example, _myService_ would be resolved as myService, and available in the function + * body as _myService_. This is useful if you want to provide a dependency to multiple + * tests without injecting it each time. + * + *
+   * 
+   *    var myService = undefined;
+   *    beforeEach( inject( function(_myService_){
+   *      myService = _myService;
+   *    })); 
+   * 
+   *    // ... use myService in a series of tests.
+   * 
+   * 
+ * * See also {@link angular.mock.module module} * * Example of what a typical jasmine tests looks like with the inject method. @@ -1920,7 +1938,7 @@ angular.mock.clearDataCache = function() { * }); * * - * + * * @param {...Function} fns any number of functions which will be injected using the injector. */ window.inject = angular.mock.inject = function() {