diff options
| author | Merrick Christensen | 2013-08-25 23:45:58 -0600 | 
|---|---|---|
| committer | Vojta Jina | 2013-09-03 14:22:12 -0700 | 
| commit | f737c97df02918eb5b19bf5c8248fa3e20f9b361 (patch) | |
| tree | 40de4c1b0fb4ef95eea9b7c02b1fac2f6163f2ee /src | |
| parent | 8e48c4ff6abf7083a04cf20312d2b106f4ba5b2c (diff) | |
| download | angular.js-f737c97df02918eb5b19bf5c8248fa3e20f9b361.tar.bz2 | |
feat(ngMock): allow passing an object literal as shorthand to module
Diffstat (limited to 'src')
| -rw-r--r-- | src/ngMock/angular-mocks.js | 16 | 
1 files changed, 13 insertions, 3 deletions
| diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 5e5041cb..6764bf17 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -1851,9 +1851,11 @@ angular.mock.clearDataCache = function() {     *     * See {@link angular.mock.inject inject} for usage example     * -   * @param {...(string|Function)} fns any number of modules which are represented as string +   * @param {...(string|Function|Object)} fns any number of modules which are represented as string     *        aliases or as anonymous module initialization functions. The modules are used to -   *        configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. +   *        configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an  +   *        object literal is passed they will be register as values in the module, the key being +   *        the module name and the value being what is returned.     */    window.module = angular.mock.module = function() {      var moduleFns = Array.prototype.slice.call(arguments, 0); @@ -1865,7 +1867,15 @@ angular.mock.clearDataCache = function() {        } else {          var modules = currentSpec.$modules || (currentSpec.$modules = []);          angular.forEach(moduleFns, function(module) { -          modules.push(module); +          if (angular.isObject(module) && !angular.isArray(module)) { +            modules.push(function($provide) { +              angular.forEach(module, function(value, key) { +                $provide.value(key, value); +              }); +            }); +          } else { +            modules.push(module); +          }          });        }      } | 
