3 * Angular-Material-Mocks
5 * Developers interested in running their own custom unit tests WITH angular-material.js loaded...
6 * must also include this *mocks* file. Similar to `angular-mocks.js`, `angular-material-mocks.js`
7 * will override and disable specific Angular Material performance settings:
9 * - Disabled Theme CSS rule generations
10 * - Forces $mdAria.expectWithText() to be synchronous
11 * - Mocks $$rAF.throttle()
12 * - Captures flush exceptions from $$rAF
15 (function(window, angular, undefined) {
21 * @name ngMaterial-mock
22 * @packageName angular-material-mocks
26 * The `ngMaterial-mock` module provides support
29 angular.module('ngMaterial-mock', ['ngMock', 'material.core'])
30 .config(['$provide', function($provide) {
33 * Angular Material dynamically generates Style tags
34 * based on themes and palletes; for each ng-app.
36 * For testing, we want to disable generation and
37 * <style> DOM injections. So we clear the huge THEME
38 * styles while testing...
40 $provide.constant('$MD_THEME_CSS', '/**/');
43 * Intercept to make .expectWithText() to be synchronous
45 $provide.decorator('$mdAria', function($delegate){
47 $delegate.expectWithText = function(element, attrName){
48 $delegate.expect(element, attrName, element.text().trim());
55 * Add throttle() and wrap .flush() to catch `no callbacks present`
58 $provide.decorator('$$rAF', function throttleInjector($delegate){
60 $delegate.throttle = function(cb) {
62 cb.apply(this, arguments);
66 var ngFlush = $delegate.flush;
67 $delegate.flush = function() {
77 })(window, window.angular);