diff options
| author | Matias Niemelä | 2014-01-15 03:43:52 -0500 | 
|---|---|---|
| committer | Matias Niemelä | 2014-01-15 03:43:52 -0500 | 
| commit | 1413328e6aec87338bf1fce002dfaf519d9ca1b5 (patch) | |
| tree | 4fea7af7dbb304a9ea4efee7082fe4d3a1bd7564 | |
| parent | 7d09bd30f9fc2c265588323817b541fd26b9abe0 (diff) | |
| download | angular.js-1413328e6aec87338bf1fce002dfaf519d9ca1b5.tar.bz2 | |
fix(ngMock): ensure ngAnimate isn't a required mock
| -rw-r--r-- | src/ngMock/angular-mocks.js | 48 | 
1 files changed, 29 insertions, 19 deletions
| diff --git a/src/ngMock/angular-mocks.js b/src/ngMock/angular-mocks.js index 803cedbd..c2c9d7a2 100644 --- a/src/ngMock/angular-mocks.js +++ b/src/ngMock/angular-mocks.js @@ -756,25 +756,35 @@ angular.mock.TzDate = function (offset, timestamp) {  angular.mock.TzDate.prototype = Date.prototype;  /* jshint +W101 */ -angular.module('ngAnimate').config(['$provide', function($provide) { -  var reflowQueue = []; -  $provide.value('$$animateReflow', function(fn) { -    reflowQueue.push(fn); -    return angular.noop; -  }); -  $provide.decorator('$animate', function($delegate) { -    $delegate.triggerReflow = function() { -      if(reflowQueue.length === 0) { -        throw new Error('No animation reflows present'); -      } -      angular.forEach(reflowQueue, function(fn) { -        fn(); -      }); -      reflowQueue = []; -    }; -    return $delegate; -  }); -}]); +// TODO(matias): remove this IMMEDIATELY once we can properly detect the +// presence of a registered module +var animateLoaded; +try { +  angular.module('ngAnimate'); +  animateLoaded = true; +} catch(e) {} + +if(animateLoaded) { +  angular.module('ngAnimate').config(['$provide', function($provide) { +    var reflowQueue = []; +    $provide.value('$$animateReflow', function(fn) { +      reflowQueue.push(fn); +      return angular.noop; +    }); +    $provide.decorator('$animate', function($delegate) { +      $delegate.triggerReflow = function() { +        if(reflowQueue.length === 0) { +          throw new Error('No animation reflows present'); +        } +        angular.forEach(reflowQueue, function(fn) { +          fn(); +        }); +        reflowQueue = []; +      }; +      return $delegate; +    }); +  }]); +}  angular.mock.animate = angular.module('mock.animate', ['ng']) | 
