diff --git a/xstatic/pkg/angular_material/data/angular-material-mocks.js b/xstatic/pkg/angular_material/data/angular-material-mocks.js new file mode 100755 index 0000000..a125108 --- /dev/null +++ b/xstatic/pkg/angular_material/data/angular-material-mocks.js @@ -0,0 +1,186 @@ +/** + * + * AngularJS-Material-Mocks + * + * Developers interested in running their own custom unit tests WITH angular-material.js loaded... + * must also include this *mocks* file. Similar to `angular-mocks.js`, `angular-material-mocks.js` + * will override and disable specific AngularJS Material performance settings: + * + * - Disabled Theme CSS rule generations + * - Forces $mdAria.expectWithText() to be synchronous + * - Mocks $$rAF.throttle() + * - Captures flush exceptions from $$rAF + * + */ +(function(window, angular, undefined) { + +'use strict'; + + // Allow our code to know when they are running inside of a test so they can expose extra services + // that should NOT be exposed to the public but that should be tested. + // + // As an example, see input.js which exposes some animation-related methods. + window._mdMocksIncluded = true; + +/** + * @ngdoc module + * @name ngMaterial-mock + * @packageName angular-material-mocks + * + * @description + * + * The `ngMaterial-mock` module provides support + * + */ +angular.module('ngMaterial-mock', [ + 'ngMock', + 'ngAnimateMock', + 'material.core' + ]) + .config(['$provide', function($provide) { + + $provide.factory('$material', ['$animate', '$timeout', function($animate, $timeout) { + return { + flushOutstandingAnimations: function() { + // this code is placed in a try-catch statement + // since 1.3 and 1.4 handle their animations differently + // and there may be situations where follow-up animations + // are run in one version and not the other + try { $animate.flush(); } catch(e) {} + }, + flushInterimElement: function() { + this.flushOutstandingAnimations(); + $timeout.flush(); + this.flushOutstandingAnimations(); + $timeout.flush(); + this.flushOutstandingAnimations(); + $timeout.flush(); + } + }; + }]); + + /** + * AngularJS Material dynamically generates Style tags + * based on themes and palletes; for each ng-app. + * + * For testing, we want to disable generation and + *