summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js')
-rw-r--r--ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js b/ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js
new file mode 100644
index 00000000..4f025786
--- /dev/null
+++ b/ecomp-portal-FE/client/bower_components/angular-material/angular-material-mocks.js
@@ -0,0 +1,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);