diff --git a/Gruntfile.js b/Gruntfile.js index b8697a1837..f886c5089b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -16,7 +16,7 @@ module.exports = function(grunt) { grunt.util.linefeed = '\n'; grunt.initConfig({ - ngversion: '1.2.10', + ngversion: '1.2.14', bsversion: '3.0.3', modules: [],//to be filled in by build task pkg: grunt.file.readJSON('package.json'), diff --git a/misc/demo/assets/app.js b/misc/demo/assets/app.js index 93101bdf4e..84fa7cc4d3 100644 --- a/misc/demo/assets/app.js +++ b/misc/demo/assets/app.js @@ -1,4 +1,4 @@ -angular.module('bootstrapDemoApp', ['ui.bootstrap', 'plunker', 'ngTouch'], function($httpProvider){ +angular.module('bootstrapDemoApp', ['ui.bootstrap', 'plunker', 'ngTouch', 'ngAnimate'], function($httpProvider){ FastClick.attach(document.body); delete $httpProvider.defaults.headers.common['X-Requested-With']; }).run(['$location', function($location){ diff --git a/misc/demo/index.html b/misc/demo/index.html index c471c6b6bd..0a60dfb740 100644 --- a/misc/demo/index.html +++ b/misc/demo/index.html @@ -10,6 +10,7 @@ + diff --git a/misc/test-lib/angular-mocks.js b/misc/test-lib/angular-mocks.js index b367f3d60b..efd029bfdd 100644 --- a/misc/test-lib/angular-mocks.js +++ b/misc/test-lib/angular-mocks.js @@ -1,5 +1,5 @@ /** - * @license AngularJS v1.2.10 + * @license AngularJS v1.2.14 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ @@ -8,7 +8,7 @@ 'use strict'; /** - * @ngdoc overview + * @ngdoc object * @name angular.mock * @description * @@ -19,7 +19,7 @@ angular.mock = {}; /** * ! This is a private undocumented service ! * - * @name ngMock.$browser + * @name $browser * * @description * This service is a mock implementation of {@link ng.$browser}. It provides fake @@ -77,8 +77,7 @@ angular.mock.$Browser = function() { /** - * @name ngMock.$browser#defer.now - * @propertyOf ngMock.$browser + * @name $browser#defer.now * * @description * Current milliseconds mock time. @@ -103,8 +102,7 @@ angular.mock.$Browser = function() { /** - * @name ngMock.$browser#defer.flush - * @methodOf ngMock.$browser + * @name $browser#defer.flush * * @description * Flushes all pending requests and executes the defer callbacks. @@ -135,8 +133,7 @@ angular.mock.$Browser = function() { angular.mock.$Browser.prototype = { /** - * @name ngMock.$browser#poll - * @methodOf ngMock.$browser + * @name $browser#poll * * @description * run all fns in pollFns @@ -187,8 +184,8 @@ angular.mock.$Browser.prototype = { /** - * @ngdoc object - * @name ngMock.$exceptionHandlerProvider + * @ngdoc provider + * @name $exceptionHandlerProvider * * @description * Configures the mock implementation of {@link ng.$exceptionHandler} to rethrow or to log errors @@ -196,8 +193,8 @@ angular.mock.$Browser.prototype = { */ /** - * @ngdoc object - * @name ngMock.$exceptionHandler + * @ngdoc service + * @name $exceptionHandler * * @description * Mock implementation of {@link ng.$exceptionHandler} that rethrows or logs errors passed @@ -205,7 +202,7 @@ angular.mock.$Browser.prototype = { * information. * * - *
+ * ```js * describe('$exceptionHandlerProvider', function() { * * it('should capture log messages and exceptions', function() { @@ -226,7 +223,7 @@ angular.mock.$Browser.prototype = { * }); * }); * }); - *+ * ``` */ angular.mock.$ExceptionHandlerProvider = function() { @@ -234,8 +231,7 @@ angular.mock.$ExceptionHandlerProvider = function() { /** * @ngdoc method - * @name ngMock.$exceptionHandlerProvider#mode - * @methodOf ngMock.$exceptionHandlerProvider + * @name $exceptionHandlerProvider#mode * * @description * Sets the logging mode. @@ -285,7 +281,7 @@ angular.mock.$ExceptionHandlerProvider = function() { /** * @ngdoc service - * @name ngMock.$log + * @name $log * * @description * Mock implementation of {@link ng.$log} that gathers all logged messages in arrays @@ -324,8 +320,7 @@ angular.mock.$LogProvider = function() { /** * @ngdoc method - * @name ngMock.$log#reset - * @methodOf ngMock.$log + * @name $log#reset * * @description * Reset all of the logging arrays to empty. @@ -333,85 +328,79 @@ angular.mock.$LogProvider = function() { $log.reset = function () { /** * @ngdoc property - * @name ngMock.$log#log.logs - * @propertyOf ngMock.$log + * @name $log#log.logs * * @description * Array of messages logged using {@link ngMock.$log#log}. * * @example - *
+ * ```js * $log.log('Some Log'); * var first = $log.log.logs.unshift(); - *+ * ``` */ $log.log.logs = []; /** * @ngdoc property - * @name ngMock.$log#info.logs - * @propertyOf ngMock.$log + * @name $log#info.logs * * @description * Array of messages logged using {@link ngMock.$log#info}. * * @example - *
+ * ```js * $log.info('Some Info'); * var first = $log.info.logs.unshift(); - *+ * ``` */ $log.info.logs = []; /** * @ngdoc property - * @name ngMock.$log#warn.logs - * @propertyOf ngMock.$log + * @name $log#warn.logs * * @description * Array of messages logged using {@link ngMock.$log#warn}. * * @example - *
+ * ```js * $log.warn('Some Warning'); * var first = $log.warn.logs.unshift(); - *+ * ``` */ $log.warn.logs = []; /** * @ngdoc property - * @name ngMock.$log#error.logs - * @propertyOf ngMock.$log + * @name $log#error.logs * * @description * Array of messages logged using {@link ngMock.$log#error}. * * @example - *
+ * ```js * $log.error('Some Error'); * var first = $log.error.logs.unshift(); - *+ * ``` */ $log.error.logs = []; /** * @ngdoc property - * @name ngMock.$log#debug.logs - * @propertyOf ngMock.$log + * @name $log#debug.logs * * @description * Array of messages logged using {@link ngMock.$log#debug}. * * @example - *
+ * ```js * $log.debug('Some Error'); * var first = $log.debug.logs.unshift(); - *+ * ``` */ $log.debug.logs = []; }; /** * @ngdoc method - * @name ngMock.$log#assertEmpty - * @methodOf ngMock.$log + * @name $log#assertEmpty * * @description * Assert that the all of the logging methods have no logged messages. If messages present, an @@ -443,12 +432,12 @@ angular.mock.$LogProvider = function() { /** * @ngdoc service - * @name ngMock.$interval + * @name $interval * * @description * Mock implementation of the $interval service. * - * Use {@link ngMock.$interval#methods_flush `$interval.flush(millis)`} to + * Use {@link ngMock.$interval#flush `$interval.flush(millis)`} to * move forward by `millis` milliseconds and trigger any functions scheduled to run in that * time. * @@ -457,7 +446,7 @@ angular.mock.$LogProvider = function() { * @param {number=} [count=0] Number of times to repeat. If not set, or 0, will repeat * indefinitely. * @param {boolean=} [invokeApply=true] If set to `false` skips model dirty checking, otherwise - * will invoke `fn` within the {@link ng.$rootScope.Scope#methods_$apply $apply} block. + * will invoke `fn` within the {@link ng.$rootScope.Scope#$apply $apply} block. * @returns {promise} A promise which will be notified on each iteration. */ angular.mock.$IntervalProvider = function() { @@ -509,8 +498,18 @@ angular.mock.$IntervalProvider = function() { nextRepeatId++; return promise; }; - + /** + * @ngdoc method + * @name $interval#cancel + * + * @description + * Cancels a task associated with the `promise`. + * + * @param {number} promise A promise from calling the `$interval` function. + * @returns {boolean} Returns `true` if the task was successfully cancelled. + */ $interval.cancel = function(promise) { + if(!promise) return false; var fnIndex; angular.forEach(repeatFns, function(fn, index) { @@ -528,8 +527,7 @@ angular.mock.$IntervalProvider = function() { /** * @ngdoc method - * @name ngMock.$interval#flush - * @methodOf ngMock.$interval + * @name $interval#flush * @description * * Runs interval tasks scheduled to be run in the next `millis` milliseconds. @@ -600,7 +598,7 @@ function padNumber(num, digits, trim) { /** - * @ngdoc object + * @ngdoc type * @name angular.mock.TzDate * @description * @@ -624,7 +622,7 @@ function padNumber(num, digits, trim) { * incomplete we might be missing some non-standard methods. This can result in errors like: * "Date.prototype.foo called on incompatible Object". * - *
+ * ```js * var newYearInBratislava = new TzDate(-1, '2009-12-31T23:00:00Z'); * newYearInBratislava.getTimezoneOffset() => -60; * newYearInBratislava.getFullYear() => 2010; @@ -633,7 +631,7 @@ function padNumber(num, digits, trim) { * newYearInBratislava.getHours() => 0; * newYearInBratislava.getMinutes() => 0; * newYearInBratislava.getSeconds() => 0; - *+ * ``` * */ angular.mock.TzDate = function (offset, timestamp) { @@ -763,70 +761,43 @@ angular.mock.TzDate = function (offset, timestamp) { angular.mock.TzDate.prototype = Date.prototype; /* jshint +W101 */ -// TODO(matias): remove this IMMEDIATELY once we can properly detect the -// presence of a registered module -var animateLoaded; -try { - angular.module('ngAnimate'); - animateLoaded = true; -} catch(e) {} +angular.mock.animate = angular.module('ngAnimateMock', ['ng']) + + .config(['$provide', function($provide) { -if(animateLoaded) { - angular.module('ngAnimate').config(['$provide', function($provide) { var reflowQueue = []; $provide.value('$$animateReflow', function(fn) { + var index = reflowQueue.length; reflowQueue.push(fn); - return angular.noop; - }); - $provide.decorator('$animate', function($delegate) { - $delegate.triggerReflow = function() { - if(reflowQueue.length === 0) { - throw new Error('No animation reflows present'); - } - angular.forEach(reflowQueue, function(fn) { - fn(); - }); - reflowQueue = []; + return function cancel() { + reflowQueue.splice(index, 1); }; - return $delegate; }); - }]); -} - -angular.mock.animate = angular.module('mock.animate', ['ng']) - .config(['$provide', function($provide) { - - $provide.decorator('$animate', function($delegate) { + $provide.decorator('$animate', function($delegate, $$asyncCallback) { var animate = { queue : [], enabled : $delegate.enabled, - flushNext : function(name) { - var tick = animate.queue.shift(); - - if (!tick) throw new Error('No animation to be flushed'); - if(tick.method !== name) { - throw new Error('The next animation is not "' + name + - '", but is "' + tick.method + '"'); - } - tick.fn(); - return tick; + triggerCallbacks : function() { + $$asyncCallback.flush(); + }, + triggerReflow : function() { + angular.forEach(reflowQueue, function(fn) { + fn(); + }); + reflowQueue = []; } }; - angular.forEach(['enter','leave','move','addClass','removeClass'], function(method) { + angular.forEach( + ['enter','leave','move','addClass','removeClass','setClass'], function(method) { animate[method] = function() { - var params = arguments; animate.queue.push({ - method : method, - params : params, - element : angular.isElement(params[0]) && params[0], - parent : angular.isElement(params[1]) && params[1], - after : angular.isElement(params[2]) && params[2], - fn : function() { - $delegate[method].apply($delegate, params); - } + event : method, + element : arguments[0], + args : arguments }); + $delegate[method].apply($delegate, arguments); }; }); @@ -907,8 +878,8 @@ angular.mock.dump = function(object) { }; /** - * @ngdoc object - * @name ngMock.$httpBackend + * @ngdoc service + * @name $httpBackend * @description * Fake HTTP backend implementation suitable for unit testing applications that use the * {@link ng.$http $http service}. @@ -917,8 +888,8 @@ angular.mock.dump = function(object) { * development please see {@link ngMockE2E.$httpBackend e2e $httpBackend mock}. * * During unit testing, we want our unit tests to run quickly and have no external dependencies so - * we don’t want to send {@link https://developer.mozilla.org/en/xmlhttprequest XHR} or - * {@link http://en.wikipedia.org/wiki/JSONP JSONP} requests to a real server. All we really need is + * we don’t want to send [XHR](https://developer.mozilla.org/en/xmlhttprequest) or + * [JSONP](http://en.wikipedia.org/wiki/JSONP) requests to a real server. All we really need is * to verify whether a certain request has been sent or not, or alternatively just let the * application make requests, respond with pre-trained responses and assert that the end result is * what we expect it to be. @@ -996,20 +967,20 @@ angular.mock.dump = function(object) { * * # Flushing HTTP requests * - * The $httpBackend used in production, always responds to requests with responses asynchronously. - * If we preserved this behavior in unit testing, we'd have to create async unit tests, which are - * hard to write, follow and maintain. At the same time the testing mock, can't respond + * The $httpBackend used in production always responds to requests with responses asynchronously. + * If we preserved this behavior in unit testing we'd have to create async unit tests, which are + * hard to write, understand, and maintain. However, the testing mock can't respond * synchronously because that would change the execution of the code under test. For this reason the * mock $httpBackend has a `flush()` method, which allows the test to explicitly flush pending - * requests and thus preserving the async api of the backend, while allowing the test to execute + * requests and thus preserve the async api of the backend while allowing the test to execute * synchronously. * * * # Unit testing with mock $httpBackend - * The following code shows how to setup and use the mock backend in unit testing a controller. - * First we create the controller under test + * The following code shows how to setup and use the mock backend when unit testing a controller. + * First we create the controller under test: * -
+ ```js // The controller code function MyController($scope, $http) { var authToken; @@ -1030,11 +1001,11 @@ angular.mock.dump = function(object) { }); }; } -+ ``` * - * Now we setup the mock backend and create the test specs. + * Now we setup the mock backend and create the test specs: * -
+ ```js // testing controller describe('MyController', function() { var $httpBackend, $rootScope, createController; @@ -1100,7 +1071,7 @@ angular.mock.dump = function(object) { $httpBackend.flush(); }); }); -+ ``` */ angular.mock.$HttpBackendProvider = function() { this.$get = ['$rootScope', createHttpBackendMock]; @@ -1210,8 +1181,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#when - * @methodOf ngMock.$httpBackend + * @name $httpBackend#when * @description * Creates a new backend definition. * @@ -1250,8 +1220,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenGET - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenGET * @description * Creates a new backend definition for GET requests. For more info see `when()`. * @@ -1263,8 +1232,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenHEAD - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenHEAD * @description * Creates a new backend definition for HEAD requests. For more info see `when()`. * @@ -1276,8 +1244,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenDELETE - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenDELETE * @description * Creates a new backend definition for DELETE requests. For more info see `when()`. * @@ -1289,8 +1256,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenPOST - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenPOST * @description * Creates a new backend definition for POST requests. For more info see `when()`. * @@ -1304,8 +1270,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenPUT - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenPUT * @description * Creates a new backend definition for PUT requests. For more info see `when()`. * @@ -1319,8 +1284,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#whenJSONP - * @methodOf ngMock.$httpBackend + * @name $httpBackend#whenJSONP * @description * Creates a new backend definition for JSONP requests. For more info see `when()`. * @@ -1333,8 +1297,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expect - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expect * @description * Creates a new request expectation. * @@ -1367,8 +1330,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectGET - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectGET * @description * Creates a new request expectation for GET requests. For more info see `expect()`. * @@ -1380,8 +1342,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectHEAD - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectHEAD * @description * Creates a new request expectation for HEAD requests. For more info see `expect()`. * @@ -1393,8 +1354,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectDELETE - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectDELETE * @description * Creates a new request expectation for DELETE requests. For more info see `expect()`. * @@ -1406,8 +1366,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectPOST - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectPOST * @description * Creates a new request expectation for POST requests. For more info see `expect()`. * @@ -1422,8 +1381,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectPUT - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectPUT * @description * Creates a new request expectation for PUT requests. For more info see `expect()`. * @@ -1438,8 +1396,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectPATCH - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectPATCH * @description * Creates a new request expectation for PATCH requests. For more info see `expect()`. * @@ -1454,8 +1411,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#expectJSONP - * @methodOf ngMock.$httpBackend + * @name $httpBackend#expectJSONP * @description * Creates a new request expectation for JSONP requests. For more info see `expect()`. * @@ -1468,8 +1424,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#flush - * @methodOf ngMock.$httpBackend + * @name $httpBackend#flush * @description * Flushes all pending requests using the trained responses. * @@ -1497,8 +1452,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#verifyNoOutstandingExpectation - * @methodOf ngMock.$httpBackend + * @name $httpBackend#verifyNoOutstandingExpectation * @description * Verifies that all of the requests defined via the `expect` api were made. If any of the * requests were not made, verifyNoOutstandingExpectation throws an exception. @@ -1506,9 +1460,9 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { * Typically, you would call this method following each test case that asserts requests using an * "afterEach" clause. * - *
+ * ```js * afterEach($httpBackend.verifyNoOutstandingExpectation); - *+ * ``` */ $httpBackend.verifyNoOutstandingExpectation = function() { $rootScope.$digest(); @@ -1520,17 +1474,16 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#verifyNoOutstandingRequest - * @methodOf ngMock.$httpBackend + * @name $httpBackend#verifyNoOutstandingRequest * @description * Verifies that there are no outstanding requests that need to be flushed. * * Typically, you would call this method following each test case that asserts requests using an * "afterEach" clause. * - *
+ * ```js * afterEach($httpBackend.verifyNoOutstandingRequest); - *+ * ``` */ $httpBackend.verifyNoOutstandingRequest = function() { if (responses.length) { @@ -1541,8 +1494,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) { /** * @ngdoc method - * @name ngMock.$httpBackend#resetExpectations - * @methodOf ngMock.$httpBackend + * @name $httpBackend#resetExpectations * @description * Resets all request expectations, but preserves all backend definitions. Typically, you would * call resetExpectations during a multiple-phase test when you want to reuse the same instance of @@ -1665,8 +1617,8 @@ function MockXhr() { /** - * @ngdoc function - * @name ngMock.$timeout + * @ngdoc service + * @name $timeout * @description * * This service is just a simple decorator for {@link ng.$timeout $timeout} service @@ -1677,8 +1629,7 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) { /** * @ngdoc method - * @name ngMock.$timeout#flush - * @methodOf ngMock.$timeout + * @name $timeout#flush * @description * * Flushes the queue of pending tasks. @@ -1691,8 +1642,7 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) { /** * @ngdoc method - * @name ngMock.$timeout#verifyNoPendingTasks - * @methodOf ngMock.$timeout + * @name $timeout#verifyNoPendingTasks * @description * * Verifies that there are no pending tasks that need to be flushed. @@ -1716,6 +1666,48 @@ angular.mock.$TimeoutDecorator = function($delegate, $browser) { return $delegate; }; +angular.mock.$RAFDecorator = function($delegate) { + var queue = []; + var rafFn = function(fn) { + var index = queue.length; + queue.push(fn); + return function() { + queue.splice(index, 1); + }; + }; + + rafFn.supported = $delegate.supported; + + rafFn.flush = function() { + if(queue.length === 0) { + throw new Error('No rAF callbacks present'); + } + + var length = queue.length; + for(var i=0;i
+ * ```js * myAppDev = angular.module('myAppDev', ['myApp', 'ngMockE2E']); * myAppDev.run(function($httpBackend) { * phones = [{name: 'phone1'}, {name: 'phone2'}]; @@ -1808,15 +1803,15 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { * $httpBackend.whenGET(/^\/templates\//).passThrough(); * //... * }); - *+ * ``` * * Afterwards, bootstrap your app with this new module. */ /** * @ngdoc method - * @name ngMockE2E.$httpBackend#when - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#when + * @module ngMockE2E * @description * Creates a new backend definition. * @@ -1840,8 +1835,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenGET - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenGET + * @module ngMockE2E * @description * Creates a new backend definition for GET requests. For more info see `when()`. * @@ -1853,8 +1848,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenHEAD - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenHEAD + * @module ngMockE2E * @description * Creates a new backend definition for HEAD requests. For more info see `when()`. * @@ -1866,8 +1861,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenDELETE - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenDELETE + * @module ngMockE2E * @description * Creates a new backend definition for DELETE requests. For more info see `when()`. * @@ -1879,8 +1874,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenPOST - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenPOST + * @module ngMockE2E * @description * Creates a new backend definition for POST requests. For more info see `when()`. * @@ -1893,8 +1888,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenPUT - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenPUT + * @module ngMockE2E * @description * Creates a new backend definition for PUT requests. For more info see `when()`. * @@ -1907,8 +1902,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenPATCH - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenPATCH + * @module ngMockE2E * @description * Creates a new backend definition for PATCH requests. For more info see `when()`. * @@ -1921,8 +1916,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) { /** * @ngdoc method - * @name ngMockE2E.$httpBackend#whenJSONP - * @methodOf ngMockE2E.$httpBackend + * @name $httpBackend#whenJSONP + * @module ngMockE2E * @description * Creates a new backend definition for JSONP requests. For more info see `when()`. * @@ -1954,7 +1949,7 @@ if(window.jasmine || window.mocha) { var currentSpec = null, isSpecRunning = function() { - return currentSpec && (window.mocha || currentSpec.queue.running); + return !!currentSpec; }; @@ -2039,7 +2034,7 @@ if(window.jasmine || window.mocha) { * *NOTE*: This function is also published on window for easy access.
+ * ```js * * angular.module('myApplicationModule', []) * .value('mode', 'app') @@ -2111,7 +2106,7 @@ if(window.jasmine || window.mocha) { * }); * }); * - *+ * ``` * * @param {...Function} fns any number of functions which will be injected using the injector. */ @@ -2132,7 +2127,7 @@ if(window.jasmine || window.mocha) { window.inject = angular.mock.inject = function() { var blockFns = Array.prototype.slice.call(arguments, 0); var errorForStack = new Error('Declaration Location'); - return isSpecRunning() ? workFn() : workFn; + return isSpecRunning() ? workFn.call(currentSpec) : workFn; ///////////////////// function workFn() { var modules = currentSpec.$modules || []; diff --git a/misc/test-lib/angular.js b/misc/test-lib/angular.js index b8621a9a2d..83146684bf 100644 --- a/misc/test-lib/angular.js +++ b/misc/test-lib/angular.js @@ -1,5 +1,5 @@ /** - * @license AngularJS v1.2.10 + * @license AngularJS v1.2.14 * (c) 2010-2014 Google, Inc. http://angularjs.org * License: MIT */ @@ -30,7 +30,7 @@ * should all be static strings, not variables or general expressions. * * @param {string} module The namespace to use for the new minErr instance. - * @returns {function(string, string, ...): Error} instance + * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance */ function minErr(module) { @@ -68,7 +68,7 @@ function minErr(module) { return match; }); - message = message + '\nhttp://errors.angularjs.org/1.2.10/' + + message = message + '\nhttp://errors.angularjs.org/1.2.14/' + (module ? module + '/' : '') + code; for (i = 2; i < arguments.length; i++) { message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' + @@ -160,14 +160,31 @@ function minErr(module) { -assertNotHasOwnProperty, -getter, -getBlockElements, + -hasOwnProperty, */ //////////////////////////////////// +/** + * @ngdoc module + * @name ng + * @module ng + * @description + * + * # ng (core module) + * The ng module is loaded by default when an AngularJS application is started. The module itself + * contains the essential components for an AngularJS application to function. The table below + * lists a high level breakdown of each of the services/factories, filters, directives and testing + * components available within this core module. + * + * + */ + /** * @ngdoc function * @name angular.lowercase + * @module ng * @function * * @description Converts the specified string to lowercase. @@ -175,11 +192,12 @@ function minErr(module) { * @returns {string} Lowercased string. */ var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;}; - +var hasOwnProperty = Object.prototype.hasOwnProperty; /** * @ngdoc function * @name angular.uppercase + * @module ng * @function * * @description Converts the specified string to uppercase. @@ -263,6 +281,7 @@ function isArrayLike(obj) { /** * @ngdoc function * @name angular.forEach + * @module ng * @function * * @description @@ -271,17 +290,17 @@ function isArrayLike(obj) { * is the value of an object property or an array element and `key` is the object property key or * array element index. Specifying a `context` for the function is optional. * - * It is worth nothing that `.forEach` does not iterate over inherited properties because it filters + * It is worth noting that `.forEach` does not iterate over inherited properties because it filters * using the `hasOwnProperty` method. * -
+ ```js var values = {name: 'misko', gender: 'male'}; var log = []; angular.forEach(values, function(value, key){ this.push(key + ': ' + value); }, log); - expect(log).toEqual(['name: misko', 'gender:male']); -+ expect(log).toEqual(['name: misko', 'gender: male']); + ``` * * @param {Object|Array} obj Object to iterate over. * @param {Function} iterator Iterator function. @@ -349,7 +368,7 @@ function reverseParams(iteratorFn) { * the number string gets longer over time, and it can also overflow, where as the nextId * will grow much slower, it is a string, and it will never overflow. * - * @returns an unique alpha-numeric string + * @returns {string} an unique alpha-numeric string */ function nextUid() { var index = uid.length; @@ -391,6 +410,7 @@ function setHashKey(obj, h) { /** * @ngdoc function * @name angular.extend + * @module ng * @function * * @description @@ -427,17 +447,18 @@ function inherit(parent, extra) { /** * @ngdoc function * @name angular.noop + * @module ng * @function * * @description * A function that performs no operations. This function can be useful when writing code in the * functional style. -
+ ```js function foo(callback) { var result = calculateResult(); (callback || angular.noop)(result); } -+ ``` */ function noop() {} noop.$inject = []; @@ -446,17 +467,18 @@ noop.$inject = []; /** * @ngdoc function * @name angular.identity + * @module ng * @function * * @description * A function that returns its first argument. This function is useful when writing code in the * functional style. * -
+ ```js function transformer(transformationFn, value) { return (transformationFn || angular.identity)(value); }; -+ ``` */ function identity($) {return $;} identity.$inject = []; @@ -467,6 +489,7 @@ function valueFn(value) {return function() {return value;};} /** * @ngdoc function * @name angular.isUndefined + * @module ng * @function * * @description @@ -481,6 +504,7 @@ function isUndefined(value){return typeof value === 'undefined';} /** * @ngdoc function * @name angular.isDefined + * @module ng * @function * * @description @@ -495,11 +519,12 @@ function isDefined(value){return typeof value !== 'undefined';} /** * @ngdoc function * @name angular.isObject + * @module ng * @function * * @description * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not - * considered to be objects. + * considered to be objects. Note that JavaScript arrays are objects. * * @param {*} value Reference to check. * @returns {boolean} True if `value` is an `Object` but not `null`. @@ -510,6 +535,7 @@ function isObject(value){return value != null && typeof value === 'object';} /** * @ngdoc function * @name angular.isString + * @module ng * @function * * @description @@ -524,6 +550,7 @@ function isString(value){return typeof value === 'string';} /** * @ngdoc function * @name angular.isNumber + * @module ng * @function * * @description @@ -538,6 +565,7 @@ function isNumber(value){return typeof value === 'number';} /** * @ngdoc function * @name angular.isDate + * @module ng * @function * * @description @@ -554,6 +582,7 @@ function isDate(value){ /** * @ngdoc function * @name angular.isArray + * @module ng * @function * * @description @@ -570,6 +599,7 @@ function isArray(value) { /** * @ngdoc function * @name angular.isFunction + * @module ng * @function * * @description @@ -638,6 +668,7 @@ var trim = (function() { /** * @ngdoc function * @name angular.isElement + * @module ng * @function * * @description @@ -649,7 +680,7 @@ var trim = (function() { function isElement(node) { return !!(node && (node.nodeName // we are a direct element - || (node.on && node.find))); // we have an on and find method part of jQuery API + || (node.prop && node.attr && node.find))); // we have an on and find method part of jQuery API } /** @@ -748,6 +779,7 @@ function isLeafNode (node) { /** * @ngdoc function * @name angular.copy + * @module ng * @function * * @description @@ -766,8 +798,8 @@ function isLeafNode (node) { * @returns {*} The copy or updated `destination`, if `destination` was specified. * * @example -