vendor/assets/javascripts/unstable/angular-mocks.js in angularjs-rails-1.2.22 vs vendor/assets/javascripts/unstable/angular-mocks.js in angularjs-rails-1.2.25

- old
+ new

@@ -1,7 +1,7 @@ /** - * @license AngularJS v1.3.0-beta.18 + * @license AngularJS v1.3.0-rc.3 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ (function(window, angular, undefined) { @@ -61,10 +61,12 @@ ); return listener; }; + self.$$checkUrlChange = angular.noop; + self.cookieHash = {}; self.lastCookieHash = {}; self.deferredFns = []; self.deferredNextId = 0; @@ -123,11 +125,11 @@ while (self.deferredFns.length && self.deferredFns[0].time <= self.defer.now) { self.deferredFns.shift().fn(); } }; - self.$$baseHref = ''; + self.$$baseHref = '/'; self.baseHref = function() { return this.$$baseHref; }; }; angular.mock.$Browser.prototype = { @@ -772,18 +774,26 @@ return function cancel() { reflowQueue.splice(index, 1); }; }); - $provide.decorator('$animate', ['$delegate', '$$asyncCallback', - function($delegate, $$asyncCallback) { + $provide.decorator('$animate', ['$delegate', '$$asyncCallback', '$timeout', '$browser', + function($delegate, $$asyncCallback, $timeout, $browser) { var animate = { queue : [], + cancel : $delegate.cancel, enabled : $delegate.enabled, - triggerCallbacks : function() { + triggerCallbackEvents : function() { $$asyncCallback.flush(); }, + triggerCallbackPromise : function() { + $timeout.flush(0); + }, + triggerCallbacks : function() { + this.triggerCallbackEvents(); + this.triggerCallbackPromise(); + }, triggerReflow : function() { angular.forEach(reflowQueue, function(fn) { fn(); }); reflowQueue = []; @@ -1485,25 +1495,25 @@ * * @param {number=} count Number of responses to flush (in the order they arrived). If undefined, * all pending requests will be flushed. If there are no pending requests when the flush method * is called an exception is thrown (as this typically a sign of programming error). */ - $httpBackend.flush = function(count) { - $rootScope.$digest(); + $httpBackend.flush = function(count, digest) { + if (digest !== false) $rootScope.$digest(); if (!responses.length) throw new Error('No pending request to flush !'); - if (angular.isDefined(count)) { + if (angular.isDefined(count) && count !== null) { while (count--) { if (!responses.length) throw new Error('No more pending request to flush !'); responses.shift()(); } } else { while (responses.length) { responses.shift()(); } } - $httpBackend.verifyNoOutstandingExpectation(); + $httpBackend.verifyNoOutstandingExpectation(digest); }; /** * @ngdoc method @@ -1517,12 +1527,12 @@ * * ```js * afterEach($httpBackend.verifyNoOutstandingExpectation); * ``` */ - $httpBackend.verifyNoOutstandingExpectation = function() { - $rootScope.$digest(); + $httpBackend.verifyNoOutstandingExpectation = function(digest) { + if (digest !== false) $rootScope.$digest(); if (expectations.length) { throw new Error('Unsatisfied requests: ' + expectations.join(', ')); } }; @@ -2006,32 +2016,10 @@ angular.mock.e2e = {}; angular.mock.e2e.$httpBackendDecorator = ['$rootScope', '$delegate', '$browser', createHttpBackendMock]; -angular.mock.clearDataCache = function() { - // jQuery 2.x doesn't expose data attached to elements. We could use jQuery.cleanData - // to clean up after elements but we'd first need to know which elements to clean up after. - // Skip it then. - if (window.jQuery) { - return; - } - - var key, - cache = angular.element.cache; - - for(key in cache) { - if (Object.prototype.hasOwnProperty.call(cache,key)) { - var handle = cache[key].handle; - - handle && angular.element(handle.elem).off(); - delete cache[key]; - } - } -}; - - if(window.jasmine || window.mocha) { var currentSpec = null, isSpecRunning = function() { return !!currentSpec; @@ -2058,12 +2046,10 @@ if (injector) { injector.get('$rootElement').off(); injector.get('$browser').pollFns.length = 0; } - angular.mock.clearDataCache(); - // clean up jquery's fragment cache angular.forEach(angular.element.fragments, function(val, key) { delete angular.element.fragments[key]; }); @@ -2079,10 +2065,11 @@ * @ngdoc function * @name angular.mock.module * @description * * *NOTE*: This function is also published on window for easy access.<br> + * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha * * This function registers a module configuration code. It collects the configuration information * which will be used when the injector is created by {@link angular.mock.inject inject}. * * See {@link angular.mock.inject inject} for usage example @@ -2121,9 +2108,10 @@ * @ngdoc function * @name angular.mock.inject * @description * * *NOTE*: This function is also published on window for easy access.<br> + * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha * * The inject function wraps a function into an injectable function. The inject() creates new * instance of {@link auto.$injector $injector} per test, which is then used for * resolving references. *