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