nexus site path corrected
[portal.git] / ecomp-portal-FE / client / bower_components / angular-material / angular-material-mocks.js
1 /**
2  *
3  * Angular-Material-Mocks
4  *
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:
8  *
9  *  - Disabled Theme CSS rule generations
10  *  - Forces $mdAria.expectWithText() to be synchronous
11  *  - Mocks $$rAF.throttle()
12  *  - Captures flush exceptions from $$rAF
13  *
14  */
15 (function(window, angular, undefined) {
16
17 'use strict';
18
19 /**
20  * @ngdoc module
21  * @name ngMaterial-mock
22  * @packageName angular-material-mocks
23  *
24  * @description
25  *
26  * The `ngMaterial-mock` module provides support
27  *
28  */
29 angular.module('ngMaterial-mock', ['ngMock', 'material.core'])
30        .config(['$provide', function($provide) {
31
32     /**
33       * Angular Material dynamically generates Style tags
34       * based on themes and palletes; for each ng-app.
35       *
36       * For testing, we want to disable generation and
37       * <style> DOM injections. So we clear the huge THEME
38       * styles while testing...
39       */
40      $provide.constant('$MD_THEME_CSS', '/**/');
41
42     /**
43      * Intercept to make .expectWithText() to be synchronous
44      */
45     $provide.decorator('$mdAria', function($delegate){
46
47       $delegate.expectWithText = function(element, attrName){
48         $delegate.expect(element, attrName, element.text().trim());
49       };
50
51       return $delegate;
52     });
53
54     /**
55      * Add throttle() and wrap .flush() to catch `no callbacks present`
56      * errors
57      */
58     $provide.decorator('$$rAF', function throttleInjector($delegate){
59
60       $delegate.throttle = function(cb) {
61         return function() {
62           cb.apply(this, arguments);
63         };
64       };
65
66       var ngFlush = $delegate.flush;
67       $delegate.flush = function() {
68           try      { ngFlush();  }
69           catch(e) { ;           }
70       };
71
72       return $delegate;
73     });
74
75   }]);
76
77 })(window, window.angular);