aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/content/api/angular.module.NG.ngdoc5
-rw-r--r--docs/content/api/angular.module.ngdoc54
-rw-r--r--docs/spec/domSpec.js2
-rw-r--r--docs/spec/ngdocSpec.js2
-rw-r--r--docs/src/dom.js16
-rw-r--r--docs/src/ngdoc.js26
-rw-r--r--docs/src/templates/docs.css14
-rw-r--r--src/Browser.js2
-rw-r--r--src/Injector.js251
-rw-r--r--src/angular-mocks.js313
-rw-r--r--src/apis.js2
-rw-r--r--src/scenario/Application.js6
-rw-r--r--src/scenario/Describe.js12
-rw-r--r--src/scenario/Future.js8
-rw-r--r--src/scenario/ObjectModel.js2
-rw-r--r--src/scenario/Runner.js12
-rw-r--r--src/scenario/Scenario.js10
-rw-r--r--src/scenario/SpecRunner.js10
-rw-r--r--src/scenario/output/Html.js2
-rw-r--r--src/service/exceptionHandler.js2
-rw-r--r--src/service/formFactory.js4
-rw-r--r--test/angular-mocksSpec.js52
-rw-r--r--test/matchers.js2
-rw-r--r--test/scenario/RunnerSpec.js4
-rw-r--r--test/service/cookiesSpec.js2
-rw-r--r--test/service/filter/filtersSpec.js8
-rw-r--r--test/service/logSpec.js2
-rw-r--r--test/testabilityPatch.js6
28 files changed, 626 insertions, 205 deletions
diff --git a/docs/content/api/angular.module.NG.ngdoc b/docs/content/api/angular.module.NG.ngdoc
new file mode 100644
index 00000000..84bb574b
--- /dev/null
+++ b/docs/content/api/angular.module.NG.ngdoc
@@ -0,0 +1,5 @@
+@ngdoc overview
+@name angular.module.NG
+@description
+
+The `NG` is an angular module which contains all of the core angular services.
diff --git a/docs/content/api/angular.module.ngdoc b/docs/content/api/angular.module.ngdoc
new file mode 100644
index 00000000..91cd311d
--- /dev/null
+++ b/docs/content/api/angular.module.ngdoc
@@ -0,0 +1,54 @@
+@ngdoc overview
+@name angular.module
+@description
+
+The angular.module namespace is a global place for registering angular modules. All modules
+(angular core or 3rd party) that should be available to an application must be registered in this
+namespace.
+
+# Module
+
+A module is a function that is used to register new service providers and configure existing
+providers. Once a provider is registered, {@link angular.module.AUTO.$injector $injector} will use
+it to ask for a service instance when it is resolving a dependency for the first time.
+
+<pre>
+// Declare the module configuration function.
+// The function arguments are fully injectable so that the module function
+// can create new providers or configure existing ones.
+function MyModule($provide, $locationProvider){
+ // see $provide for more information.
+ $provide.value('appName', 'MyCoolApp');
+
+ // Configure existing providers
+ $locationProvider.hashPrefix = '!';
+};
+</pre>
+
+See: {@link angular.module.NG.$provide $provide}, {@link angular.module.NG.$locationProvider $locationProvider}.
+
+# Registering Module Function
+
+In your JavaScript file:
+<pre>
+// Create the angular.module namespace if one does not exist
+// This allows the module code to be loaded before angular.js code.
+if (!window.angular) window.angular = {};
+if (!angular.module) angular.module = {};
+
+angular.module.MyModule = function(){
+ // add configuration code here.
+};
+</pre>
+
+Then you can refer to your module like this:
+
+<pre>
+var injector = angular.injector('NG', 'MyModule')
+</pre>
+
+Or
+
+<pre>
+var injector = angular.injector('NG', angular.module.MyModule)
+</pre>
diff --git a/docs/spec/domSpec.js b/docs/spec/domSpec.js
index a967645e..5175b91a 100644
--- a/docs/spec/domSpec.js
+++ b/docs/spec/domSpec.js
@@ -24,7 +24,7 @@ describe('dom', function() {
dom.h('heading', function() {
this.html('<h1>sub-heading</h1>');
});
- expect(dom.toString()).toContain('<h1>heading</h1>');
+ expect(dom.toString()).toContain('<h1 id="heading">heading</h1>');
expect(dom.toString()).toContain('<h2>sub-heading</h2>');
});
diff --git a/docs/spec/ngdocSpec.js b/docs/spec/ngdocSpec.js
index 367f91b4..bc2bb2ee 100644
--- a/docs/spec/ngdocSpec.js
+++ b/docs/spec/ngdocSpec.js
@@ -528,7 +528,7 @@ describe('ngdoc', function() {
returns: {type: 'number', description: 'return desc'}
});
doc.html_usage_function(dom);
- expect(dom).toContain('some.name([a][, b], c)'); //TODO(i) the comma position here is lame
+ expect(dom).toContain('name([a][, b], c)'); //TODO(i) the comma position here is lame
expect(dom).toContain('param desc');
expect(dom).toContain('(optional="xxx")');
expect(dom).toContain('return desc');
diff --git a/docs/src/dom.js b/docs/src/dom.js
index ccfee7ac..11330a02 100644
--- a/docs/src/dom.js
+++ b/docs/src/dom.js
@@ -77,10 +77,18 @@ DOM.prototype = {
h: function(heading, content, fn){
if (content==undefined || (content instanceof Array && content.length == 0)) return;
this.headingDepth++;
- this.tag('h' + this.headingDepth, heading);
- var className = typeof heading == 'string'
- ? {'class': heading.toLowerCase().replace(/[^\d\w_]/mg, '-').replace(/-+/gm, '-')}
- : null;
+ var className = null,
+ anchor = null;
+ if (typeof heading == 'string') {
+ var id = heading.
+ replace(/\(.*\)/mg, '').
+ replace(/[^\d\w]/mg, '.').
+ replace(/-+/gm, '-').
+ replace(/-*$/gm, '');
+ anchor = {'id': id};
+ className = {'class': id.toLowerCase().replace(/[._]/mg, '-')};
+ }
+ this.tag('h' + this.headingDepth, anchor, heading);
if (content instanceof Array) {
this.ul(content, className, fn);
} else if (fn) {
diff --git a/docs/src/ngdoc.js b/docs/src/ngdoc.js
index 562144b5..7f97b906 100644
--- a/docs/src/ngdoc.js
+++ b/docs/src/ngdoc.js
@@ -89,6 +89,7 @@ Doc.prototype = {
var self = this,
IS_URL = /^(https?:\/\/|ftps?:\/\/|mailto:|\.|\/)/,
IS_ANGULAR = /^(api\/)?angular\./,
+ IS_HASH = /^#/,
parts = trim(text).split(/(<pre>[\s\S]*?<\/pre>|<doc:(\S*).*?>[\s\S]*?<\/doc:\2>)/);
parts.forEach(function(text, i) {
@@ -134,13 +135,16 @@ Doc.prototype = {
function(_all, url, title){
var isFullUrl = url.match(IS_URL),
isAngular = url.match(IS_ANGULAR),
- absUrl = isFullUrl ? url : self.convertUrlToAbsolute(url);
+ isHash = url.match(IS_HASH),
+ absUrl = isHash
+ ? url
+ : (isFullUrl ? url : self.convertUrlToAbsolute(url));
if (!isFullUrl) self.links.push(absUrl);
return '<a href="' + absUrl + '">' +
(isAngular ? '<code>' : '') +
- (title || url).replace(/\n/g, ' ') +
+ (title || url.replace(/^#/g, '')).replace(/\n/g, ' ') +
(isAngular ? '</code>' : '') +
'</a>';
});
@@ -171,7 +175,8 @@ Doc.prototype = {
}
});
flush();
- this.shortName = (this.name || '').split(/[\.#]/).pop();
+ this.name = this.name || '';
+ this.shortName = this.name.split(this.name.match(/#/) ? /#/ : /\./ ).pop();
this.id = this.id || // if we have an id just use it
(((this.file||'').match(/.*\/([^\/]*)\.ngdoc/)||{})[1]) || // try to extract it from file name
this.name; // default to name
@@ -319,7 +324,7 @@ Doc.prototype = {
var self = this;
dom.h('Usage', function() {
dom.code(function() {
- dom.text(self.name.split('service.').pop());
+ dom.text(self.name.split(/\./).pop());
dom.text('(');
self.parameters(dom, ', ');
dom.text(');');
@@ -329,6 +334,7 @@ Doc.prototype = {
self.html_usage_this(dom);
self.html_usage_returns(dom);
});
+ this.method_properties_events(dom);
},
html_usage_property: function(dom){
@@ -450,7 +456,7 @@ Doc.prototype = {
dom.html(this.description);
},
- html_usage_service: function(dom){
+ html_usage_object: function(dom){
var self = this;
if (this.param.length) {
@@ -467,7 +473,15 @@ Doc.prototype = {
self.html_usage_returns(dom);
});
}
+ this.method_properties_events(dom);
+ },
+
+ html_usage_service: function(dom) {
+ this.html_usage_object(dom)
+ },
+ method_properties_events: function(dom) {
+ var self = this;
dom.h('Methods', this.methods, function(method){
var signature = (method.param || []).map(property('name'));
dom.h(method.shortName + '(' + signature.join(', ') + ')', method, function() {
@@ -480,7 +494,7 @@ Doc.prototype = {
});
});
dom.h('Properties', this.properties, function(property){
- dom.h(property.name, function() {
+ dom.h(property.shortName, function() {
dom.html(property.description);
dom.h('Example', property.example, dom.html);
});
diff --git a/docs/src/templates/docs.css b/docs/src/templates/docs.css
index 5c7a064a..fd77970c 100644
--- a/docs/src/templates/docs.css
+++ b/docs/src/templates/docs.css
@@ -240,23 +240,25 @@ li {
}
#content-list .level-1 {
- font-size: 1.1em;
- font-weight: bold;
+ margin-left: 0em;
}
-#content-list .level-2,
-#content-list .level-3 {
+#content-list .level-2 {
margin-left: 1em;
}
-#content-list .level-4 {
+#content-list .level-3 {
margin-left: 2em;
}
-#content-list .level-5 {
+#content-list .level-4 {
margin-left: 3em;
}
+#content-list .level-5 {
+ margin-left: 4em;
+}
+
#content-list a.current {
font-weight: bold;
diff --git a/src/Browser.js b/src/Browser.js
index d4faebc8..84d9cd44 100644
--- a/src/Browser.js
+++ b/src/Browser.js
@@ -24,7 +24,7 @@ var XHR = window.XMLHttpRequest || function() {
* - hide all the global state in the browser caused by the window object
* - abstract away all the browser specific features and inconsistencies
*
- * For tests we provide {@link angular.mock.service.$browser mock implementation} of the `$browser`
+ * For tests we provide {@link angular.module.NG_MOCK.$browser mock implementation} of the `$browser`
* service, which can be used for convenient testing of the application without the interaction with
* the real browser apis.
*/
diff --git a/src/Injector.js b/src/Injector.js
index 58b30fda..fbc6d3a0 100644
--- a/src/Injector.js
+++ b/src/Injector.js
@@ -9,37 +9,35 @@
* Creates an injector function that can be used for retrieving services as well as for
* dependency injection (see {@link guide/dev_guide.di dependency injection}).
*
- * Creating an injector doesn't automatically create all of the `$eager`
- * {@link angular.service services}. You have to call `injector.eager()` to initialize them.
- *
- * @param {Object.<string, function()>=} [factories=angular.service] Map of the service factory
- * functions.
- * @returns {function()} Injector function:
- *
- * * `injector(serviceName)`:
- * * `serviceName` - `{string=}` - Name of the service to retrieve.
- *
- * The injector function also has these properties:
- *
- * * An `invoke` property which can be used to invoke methods with dependency-injected arguments.
- * `injector.invoke(self, fn, locals)`
- * * `self` - The "`this`" to be used when invoking the function.
- * * `fn` - The function to be invoked. The function may have the `$inject` property that
- * lists the set of arguments which should be auto-injected.
- * (see {@link guide/dev_guide.di dependency injection}).
- * * `locals(array)` - Optional array of arguments to pass to the function
- * invocation after the injection arguments.
- * * An `eager` property which is used to initialize the eager services.
- * `injector.eager()`
+
+ * @param {<string, function()>} modules... A list of module functions or their aliases. See
+ * {@link angular.module}. The `NG` module must be explicitly added.
+ * @returns {function()} Injector function. See {@link angular.module.AUTO.$injector $injector}.
+ *
+ * @example
+ * Typical usage
+ * <pre>
+ * // create an injector
+ * var $injector = angular.injector('NG');
+ *
+ * // use the injector to kick of your application
+ * // use the type inference to auto inject arguments, or use implicit injection
+ * $injector(function($rootScope, $compile, $document){
+ * $compile($document)($rootScope);
+ * $rootScope.$digest();
+ * });
+ * </pre>
*/
/**
- * @returns the $inject property of function. If not found the
- * the $inject is computed by looking at the toString of function and
- * extracting all arguments which and assuming that they are the
- * injection names.
+ * @ngdoc overview
+ * @name angular.module.AUTO
+ * @description
+ *
+ * Implicit module which gets automatically added to each {@link angular.module.AUTO.$injector $injector}.
*/
+
var FN_ARGS = /^function\s*[^\(]*\(([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(.+?)\s*$/;
@@ -60,6 +58,207 @@ function inferInjectionArgs(fn) {
}
///////////////////////////////////////
+
+/**
+ * @ngdoc function
+ * @name angular.module.AUTO.$injector
+ * @function
+ *
+ * @description
+ *
+ * `$injector` function is used to retrieve object instances. Object instances are defined by
+ * {@link angular.module.AUTO.$provide provider}.
+ *
+ * The following always holds true:
+ *
+ * <pre>
+ * var $injector = angular.injector();
+ * expect($injector('$injector')).toBe($injector);
+ * expect($injector(function($injector){
+ * return $injector;
+ * }).toBe($injector);
+ * </pre>
+ *
+ * # Injection Function Annotation
+ *
+ * JavaScript does not have annotations, and annotations are needed for dependency injection. The
+ * following ways are all valid way of annotating function with injection arguments and are equivalent.
+ *
+ * <pre>
+ * // inferred (only works if code not minified/obfuscated)
+ * $inject.invoke(function(serviceA){});
+ *
+ * // annotated
+ * function explicit(serviceA) {};
+ * explicit.$inject = ['serviceA'];
+ * $inject.invoke(explicit);
+ *
+ * // inline
+ * $inject.invoke(['serviceA', function(serviceA){}]);
+ * </pre>
+ *
+ * ## Inference
+ *
+ * In JavaScript calling `toString()` on a function returns the function definition. The definition can then be
+ * parsed and the function arguments can be extracted. *NOTE:* This does not work with minfication, and obfuscation
+ * tools since these tools change the argument names.
+ *
+ * ## `$inject` Annotation
+ * By adding a `$inject` property onto a function the injection parameters can be specified.
+ *
+ * ## Inline
+ * As an array of injection names, where the last item in the array is the function to call.
+ *
+ * @param {string, function()} argument If the `argument` is:
+ *
+ * - `string`: Retrieve an instance of a named object. If object does not exist, use the provider to create
+ * a new instance. Calling the method repeatedly with the same name will always return the same
+ * instance.
+ * - `function`: Invoke the function. This is a short hand for `$injector.`{@link #invoke invoke(null, argument)}.
+ * @return the object instance or the return value of the invoked function.
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$injector#invoke
+ * @methodOf angular.module.AUTO.$injector
+ *
+ * @description
+ * Invoke the method and supply the method arguments from the `$injector`.
+ *
+ * @param {Object} self The `this` for the invoked method.
+ * @param {function} fn The function to invoke. The function arguments come form the function annotation.
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this object first, before
+ * the `$injector` is consulted.
+ * @return the value returned by the invoked `fn` function.
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$injector#instantiate
+ * @methodOf angular.module.AUTO.$injector
+ * @description
+ * Create a new instance of JS type. The method takes a constructor function invokes the new operator and supplies
+ * all of the arguments to the constructor function as specified by the constructor annotation.
+ *
+ * @param {function} Type Annotated constructor function.
+ * @param {Object=} locals Optional object. If preset then any argument names are read from this object first, before
+ * the `$injector` is consulted.
+ * @return new instance of `Type`.
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$injector#loadModule
+ * @methodOf angular.module.AUTO.$injector
+ * @description
+ * Load additional modules into the current injector configuration
+ *
+ * @param {Array} modules An array of modules, where module is a:
+ *
+ * - `string`: look up the module function from {@link angular.module} and then treat as `function`.
+ * - `function`: execute the module configuration function using
+ * {@link angular.module.AUTO.$injector#invoke $injector.invoke()}
+ */
+
+
+
+/**
+ * @ngdoc object
+ * @name angular.module.AUTO.$provide
+ *
+ * @description
+ *
+ * Use `$provide` to register new providers with the `$injector`. The providers are the factories for the instance.
+ * The providers share the same name as the instance they create with the `Provide` suffixed to them.
+ *
+ * A provider is an object with a `$get()` method. The injector calls the `$get` method to create a new instance of
+ * a service. The Provider can have additional methods which would allow for configuration of the provider.
+ *
+ * <pre>
+ * function GreetProvider() {
+ * var salutation = 'Hello';
+ *
+ * this.salutation = function(text) {
+ * salutation = text;
+ * };
+ *
+ * this.$get = function() {
+ * return function (name) {
+ * return salutation + ' ' + name + '!';
+ * };
+ * };
+ * }
+ *
+ * describe('Greeter', function(){
+ *
+ * beforeEach(inject(function($provide) {
+ * $provide.service('greet', GreetProvider);
+ * });
+ *
+ * it('should greet', inject(function(greet) {
+ * expect(greet('angular')).toEqual('Hello angular!');
+ * }));
+ *
+ * it('should allow configuration of salutation', inject(
+ * function(greetProvider) {
+ * greetProvider.salutation('Ahoj');
+ * },
+ * function(greet) {
+ * expect(greet('angular')).toEqual('Ahoj angular!');
+ * }
+ * )};
+ *
+ * });
+ * </pre>
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$provide#service
+ * @methodOf angular.module.AUTO.$provide
+ * @description
+ *
+ * Register a provider for a service. The providers can be retrieved and can have additional configuration methods.
+ *
+ * @param {string} name The name of the instance. NOTE: the provider will be available under `name + 'Provide'` key.
+ * @param {(Object|function())} provider If the provider is:
+ *
+ * - `Object`: then it should have a `$get` method. The `$get` method will be invoked using
+ * {@link angular.module.AUTO.$injector#invoke $injector.invoke()} when an instance needs to be created.
+ * - `Constructor`: a new instance of the provider will be created using
+ * {@link angular.module.AUTO.$injector#instantiate $injector.instantiate()}, then treated as `object`.
+ *
+ */
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$provide#factory
+ * @methodOf angular.module.AUTO.$provide
+ * @description
+ *
+ * A short hand for configuring services if only `$get` method is required.
+ *
+ * @param {string} name The name of the instance. NOTE: the provider will be available under `name + 'Provide'` key.
+ * @param {function()} $getFn The $getFn for the instance creation. Internally this is a short hand for
+ * `$provide.service(name, {$get:$getFn})`.
+ */
+
+
+/**
+ * @ngdoc method
+ * @name angular.module.AUTO.$provide#value
+ * @methodOf angular.module.AUTO.$provide
+ * @description
+ *
+ * A short hand for configuring services if the `$get` method is a constant.
+ *
+ * @param {string} name The name of the instance. NOTE: the provider will be available under `name + 'Provide'` key.
+ * @param {function()} value The $getFn for the instance creation. Internally this is a short hand for
+ * `$provide.service(name, {$get:function(){ return value; }})`.
+ */
+
+
function createInjector(modulesToLoad, moduleRegistry) {
var cache = {},
$injector = internalInjector(cache),
diff --git a/src/angular-mocks.js b/src/angular-mocks.js
index 1757b941..1bdf0b86 100644
--- a/src/angular-mocks.js
+++ b/src/angular-mocks.js
@@ -6,69 +6,49 @@
*/
-/*
- IN THE FINAL BUILD THIS FILE DOESN'T HAVE DIRECT ACCESS TO GLOBAL FUNCTIONS
- DEFINED IN Angular.js YOU *MUST* REFER TO THEM VIA angular OBJECT
- (e.g. angular.forEach(...)) AND MAKE SURE THAT THE GIVEN FUNCTION IS EXPORTED
- TO THE angular NAMESPACE in AngularPublic.js
-
- */
-
+window.angular = window.angular || {};
+angular.module = angular.module || {};
/**
* @ngdoc overview
- * @name angular.mock
+ * @name angular.module.NG_MOCK
* @description
*
- * The `angular.mock` object is a namespace for all built-in mock services that ship with angular.
- * It automatically replaces real services if the `angular-mocks.js` file is loaded after
- * `angular.js` and before any tests.
- *
- * Built-in mocks:
- *
- * * {@link angular.mock.service.$browser $browser } - A mock implementation of the browser.
- * * {@link angular.mock.service.$exceptionHandler $exceptionHandler } - A mock implementation of
- * the angular service exception handler.
- * * {@link angular.mock.service.$log $log } - A mock implementation of the angular service log.
+ * The `NG_MOCK` is an angular module which is used with `NG` module and adds unit-test configuration as well as useful
+ * mocks to the {@link angular.module.AUTO.$injector $injector}.
*/
-window.angular = window.angular || {};
-angular.module = angular.module || {};
-angular.mock = angular.mock || {};
-
-angular.module.NG_MOCK = ['$provide', function($provide){
- $provide.service('$browser', angular.mock.$BrowserProvider);
- $provide.service('$exceptionHandler', angular.mock.$ExceptionHandlerProvider);
- $provide.service('$log', angular.mock.$LogProvider);
-}];
+angular.module.NG_MOCK = function($provide){
+ $provide.service('$browser', angular.module.NG_MOCK.$BrowserProvider);
+ $provide.service('$exceptionHandler', angular.module.NG_MOCK.$ExceptionHandlerProvider);
+ $provide.service('$log', angular.module.NG_MOCK.$LogProvider);
+};
+angular.module.NG_MOCK.$inject = ['$provide'];
/**
- * @ngdoc service
- * @name angular.mock.service.$browser
+ * @ngdoc object
+ * @name angular.module.NG_MOCK.$browser
*
* @description
- * This service is a mock implementation of {@link angular.service.$browser}. It provides fake
+ * This service is a mock implementation of {@link angular.module.NG.$browser}. It provides fake
* implementation for commonly used browser apis that are hard to test, e.g. setTimeout, xhr,
- * cookies.
+ * cookies, etc...
*
- * This implementation is automatically available and replaces regular `$browser` service in tests
- * when `angular-mocks.js` is loaded.
- *
- * The api of this service is the same as the real {@link angular.service.$browser $browser}, except
+ * The api of this service is the same as that of the real {@link angular.module.NG.$browser $browser}, except
* that there are several helper methods available which can be used in tests.
*
* The following apis can be used in tests:
*
- * - {@link angular.mock.service.$browser.xhr $browser.xhr} — enables testing of code that uses
- * the {@link angular.service.$xhr $xhr service} to make XmlHttpRequests.
+ * - {@link #xhr} — enables testing of code that uses
+ * the {@link angular.module.NG.$xhr $xhr service} to make XmlHttpRequests.
* - $browser.defer — enables testing of code that uses
- * {@link angular.service.$defer $defer service} for executing functions via the `setTimeout` api.
+ * {@link angular.module.NG.$defer $defer} for executing functions via the `setTimeout` api.
*/
-angular.mock.$BrowserProvider = function(){
+angular.module.NG_MOCK.$BrowserProvider = function(){
this.$get = function(){
- return new angular.mock.$Browser();
+ return new angular.module.NG_MOCK.$Browser();
};
};
-angular.mock.$Browser = function() {
+angular.module.NG_MOCK.$Browser = function() {
var self = this,
expectations = {},
requests = [];
@@ -96,22 +76,23 @@ angular.mock.$Browser = function() {
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Generic method for training browser to expect a request in a test and respond to it.
*
* See also convenience methods for browser training:
*
- * - {@link angular.mock.service.$browser.xhr.expectGET $browser.xhr.expectGET}
- * - {@link angular.mock.service.$browser.xhr.expectPOST $browser.xhr.expectPOST}
- * - {@link angular.mock.service.$browser.xhr.expectPUT $browser.xhr.expectPUT}
- * - {@link angular.mock.service.$browser.xhr.expectDELETE $browser.xhr.expectDELETE}
- * - {@link angular.mock.service.$browser.xhr.expectJSON $browser.xhr.expectJSON}
+ * - {@link #xhr.expectGET}
+ * - {@link #xhr.expectPOST}
+ * - {@link #xhr.expectPUT}
+ * - {@link #xhr.expectDELETE}
+ * - {@link #xhr.expectJSON}
*
* To flush pending requests in tests use
- * {@link angular.mock.service.$browser.xhr.flush $browser.xhr.flush}.
+ * {@link #xhr.flush}.
*
* @param {string} method Expected HTTP method.
* @param {string} url Url path for which a request is expected.
@@ -120,7 +101,7 @@ angular.mock.$Browser = function() {
* @param {object} headers Key-value pairs of expected headers.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link #xhr.flush flushed}.
*/
self.xhr = function(method, url, data, callback, headers) {
headers = headers || {};
@@ -158,8 +139,9 @@ angular.mock.$Browser = function() {
};
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.expectGET
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.expectGET
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Trains browser to expect a `GET` request and respond to it.
@@ -167,13 +149,14 @@ angular.mock.$Browser = function() {
* @param {string} url Url path for which a request is expected.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link angular.module.NG_MOCK.$browser.xhr.flush flushed}.
*/
self.xhr.expectGET = angular.bind(self, self.xhr.expect, 'GET');
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.expectPOST
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.expectPOST
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Trains browser to expect a `POST` request and respond to it.
@@ -181,13 +164,14 @@ angular.mock.$Browser = function() {
* @param {string} url Url path for which a request is expected.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link angular.module.NG_MOCK.$browser.xhr.flush flushed}.
*/
self.xhr.expectPOST = angular.bind(self, self.xhr.expect, 'POST');
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.expectDELETE
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.expectDELETE
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Trains browser to expect a `DELETE` request and respond to it.
@@ -195,13 +179,14 @@ angular.mock.$Browser = function() {
* @param {string} url Url path for which a request is expected.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link angular.module.NG_MOCK.$browser.xhr.flush flushed}.
*/
self.xhr.expectDELETE = angular.bind(self, self.xhr.expect, 'DELETE');
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.expectPUT
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.expectPUT
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Trains browser to expect a `PUT` request and respond to it.
@@ -209,13 +194,14 @@ angular.mock.$Browser = function() {
* @param {string} url Url path for which a request is expected.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link angular.module.NG_MOCK.$browser.xhr.flush flushed}.
*/
self.xhr.expectPUT = angular.bind(self, self.xhr.expect, 'PUT');
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.expectJSON
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.expectJSON
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Trains browser to expect a `JSON` request and respond to it.
@@ -223,13 +209,14 @@ angular.mock.$Browser = function() {
* @param {string} url Url path for which a request is expected.
* @returns {object} Response configuration object. You can call its `respond()` method to
* configure what should the browser mock return when the response is
- * {@link angular.mock.service.$browser.xhr.flush flushed}.
+ * {@link angular.module.NG_MOCK.$browser.xhr.flush flushed}.
*/
self.xhr.expectJSON = angular.bind(self, self.xhr.expect, 'JSON');
/**
- * @ngdoc function
- * @name angular.mock.service.$browser.xhr.flush
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#xhr.flush
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* Flushes all pending requests and executes xhr callbacks with the trained response as the
@@ -277,6 +264,16 @@ angular.mock.$Browser = function() {
};
+ /**
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$browser#defer.flush
+ * @methodOf angular.module.NG_MOCK.$browser
+ *
+ * @description
+ * Flushes all pending requests and executes the defer callbacks.
+ *
+ * @param {number=} number of miliseconds to flush. See {@link #defer.now}
+ */
self.defer.flush = function(delay) {
if (angular.isDefined(delay)) {
self.defer.now += delay;
@@ -290,17 +287,25 @@ angular.mock.$Browser = function() {
self.deferredFns.shift().fn();
}
};
+ /**
+ * @ngdoc property
+ * @name angular.module.NG_MOCK.$browser#defer.now
+ * @propertyOf angular.module.NG_MOCK.$browser
+ *
+ * @description
+ * Current milliseconds mock time.
+ */
self.$$baseHref = '';
self.baseHref = function() {
return this.$$baseHref;
};
}
-angular.mock.$Browser.prototype = {
+angular.module.NG_MOCK.$Browser.prototype = {
/**
- * @name angular.mock.service.$browser#poll
- * @methodOf angular.mock.service.$browser
+ * @name angular.module.NG_MOCK.$browser#poll
+ * @methodOf angular.module.NG_MOCK.$browser
*
* @description
* run all fns in pollFns
@@ -351,19 +356,45 @@ angular.mock.$Browser.prototype = {
/**
- * @ngdoc service
- * @name angular.mock.service.$exceptionHandler
+ * @ngdoc object
+ * @name angular.module.NG_MOCK.$exceptionHandlerProvider
*
* @description
- * Mock implementation of {@link angular.service.$exceptionHandler} that rethrows any error passed
- * into `$exceptionHandler`. If any errors are are passed into the handler in tests, it typically
- * means that there is a bug in the application or test, so this mock will make these tests fail.
+ * Configures the mock implementation of {@link angular.module.NG.$exceptionHandler} to rethrow or to log errors passed
+ * into the `$exceptionHandler`.
+ */
+
+/**
+ * @ngdoc object
+ * @name angular.module.NG_MOCK.$exceptionHandler
*
- * See {@link angular.mock} for more info on angular mocks.
+ * @description
+ * Mock implementation of {@link angular.module.NG.$exceptionHandler} that rethrows or logs errors passed
+ * into it. See {@link angular.module.NG_MOCK.$exceptionHandlerProvider $exceptionHandlerProvider} for configuration
+ * information.
*/
-angular.mock.$ExceptionHandlerProvider = function(){
+
+angular.module.NG_MOCK.$ExceptionHandlerProvider = function(){
var handler;
+ /**
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$exceptionHandlerProvider#mode
+ * @methodOf angular.module.NG_MOCK.$exceptionHandlerProvider
+ *
+ * @description
+ * Sets the logging mode.
+ *
+ * @param {string} mode Mode of operation, defaults to `rethrow`.
+ *
+ * - `rethrow`: If any errors are are passed into the handler in tests, it typically
+ * means that there is a bug in the application or test, so this mock will
+ * make these tests fail.
+ * - `log`: Sometimes it is desirable to test that an error is throw, for this case the `log` mode stores the
+ * error and allows later assertion of it.
+ * See {@link angular.module.NG_MOCK.$log#assertEmpty assertEmpty()} and
+ * {@link angular.module.NG_MOCK.$log#reset reset()}
+ */
this.mode = function(mode){
switch(mode) {
case 'rethrow':
@@ -393,16 +424,15 @@ angular.mock.$ExceptionHandlerProvider = function(){
/**
* @ngdoc service
- * @name angular.mock.service.$log
+ * @name angular.module.NG_MOCK.$log
*
* @description
- * Mock implementation of {@link angular.service.$log} that gathers all logged messages in arrays
+ * Mock implementation of {@link angular.module.NG.$log} that gathers all logged messages in arrays
* (one array per logging level). These arrays are exposed as `logs` property of each of the
* level-specific log function, e.g. for level `error` the array is exposed as `$log.error.logs`.
*
- * See {@link angular.mock} for more info on angular mocks.
*/
-angular.mock.$LogProvider = function(){
+angular.module.NG_MOCK.$LogProvider = function(){
function concat(array1, array2, index) {
return array1.concat(Array.prototype.slice.call(array2, index));
@@ -417,14 +447,62 @@ angular.mock.$LogProvider = function(){
error: function() { $log.error.logs.push(concat([], arguments, 0)); }
};
+ /**
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$log#reset
+ * @methodOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Reset all of the logging arrays to empty.
+ */
$log.reset = function (){
+ /**
+ * @ngdoc property
+ * @name angular.module.NG_MOCK.$log#log.logs
+ * @propertyOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Array of logged messages.
+ */
$log.log.logs = [];
+ /**
+ * @ngdoc property
+ * @name angular.module.NG_MOCK.$log#warn.logs
+ * @propertyOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Array of logged messages.
+ */
$log.warn.logs = [];
+ /**
+ * @ngdoc property
+ * @name angular.module.NG_MOCK.$log#info.logs
+ * @propertyOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Array of logged messages.
+ */
$log.info.logs = [];
+ /**
+ * @ngdoc property
+ * @name angular.module.NG_MOCK.$log#error.logs
+ * @propertyOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Array of logged messages.
+ */
$log.error.logs = [];
};
- $log.assertEmpty = function(){
+ /**
+ * @ngdoc method
+ * @name angular.module.NG_MOCK.$log#assertEmpty
+ * @methodOf angular.module.NG_MOCK.$log
+ *
+ * @description
+ * Assert that the all of the logging methods have no logged messages. If messages present, an exception is thrown.
+ */
+ $log.assertEmpty = function() {
var errors = [];
angular.forEach(['error', 'warn', 'info', 'log'], function(logLevel) {
angular.forEach($log[logLevel].logs, function(log) {
@@ -448,6 +526,12 @@ angular.mock.$LogProvider = function(){
/**
+ * @ngdoc object
+ * @name angular.module.NG_MOCK.TzDate
+ * @description
+ *
+ * *NOTE*: this is not an injectable instance, just a globally available mock class of `Date`.
+ *
* Mock of the Date type which has its timezone specified via constroctor arg.
*
* The main purpose is to create Date-like instances with timezone fixed to the specified timezone
@@ -477,7 +561,7 @@ angular.mock.$LogProvider = function(){
* </pre>
*
*/
-angular.mock.TzDate = function (offset, timestamp) {
+angular.module.NG_MOCK.TzDate = function (offset, timestamp) {
var self = new Date(0);
if (angular.isString(timestamp)) {
var tsStr = timestamp;
@@ -580,15 +664,24 @@ angular.mock.TzDate = function (offset, timestamp) {
}
//make "tzDateInstance instanceof Date" return true
-angular.mock.TzDate.prototype = Date.prototype;
+angular.module.NG_MOCK.TzDate.prototype = Date.prototype;
/**
- * Method for serializing common objects into strings, useful for debugging.
+ * @ngdoc function
+ * @name angular.module.NG_MOCK.debug
+ * @description
+ *
+ * *NOTE*: this is not an injectable instance, just a globally available function.
+ *
+ * Method for serializing common angular objects (scope, elements, etc..) into strings, useful for debugging.
+ *
+ * This method is also available on window, where it can be used to display objects on debug console.
+ *
* @param {*} object - any object to turn into string.
* @return a serialized string of the argument
*/
-angular.mock.dump = function(object){
+angular.module.NG_MOCK.dump = function(object){
var out;
if (angular.isElement(object)) {
object = angular.element(object);
@@ -633,13 +726,57 @@ window.jstestdriver && (function(window){
window.dump = function() {
var args = [];
angular.forEach(arguments, function(arg){
- args.push(angular.mock.dump(arg));
+ args.push(angular.module.NG_MOCK.dump(arg));
});
jstestdriver.console.log.apply(jstestdriver.console, args);
};
})(window);
+/**
+ * @ngdoc function
+ * @name angular.module.NG_MOCK.inject
+ * @description
+ *
+ * *NOTE*: this is not an injectable instance, just a globally available function on window.
+ *
+ * This function wraps a test method into an injectable method. It create one
+ * {@link angular.module.AUTO.$injector $injector} per test, which is then used for testing.
+ *
+ * Here is an example of what a typical jasmine tests looks like with the inject method.
+ * <pre>
+ * describe('MyApp', function() {
+ *
+ * // Argument inference is used to inject the $provide service
+ * beforeEach(inject(function($provide, $rootScope) {
+ * // $provide service is configured as needed
+ * $provide.value('version', 'v1.0.1');
+ * $rootScope.value = 123;
+ * });
+ *
+ * // Argument inference is used to inject the $rootScope as well as the version
+ * it('should provide a version', inject(function($rootScope, version){
+ * expect(version).toEqual('v1.0.1');
+ * expect($rootScope.value).toEqual(123);
+ * });
+ *
+ * // The inject can also chain the methods
+ * it('should override a version and test the new version is injected', inject(
+ * function($provide) {
+ * $provide.value('version', 'overridden'); // override version here
+ * },
+ * function(version) {
+ * expect(version).toEqual('overridden');
+ * }
+ * ));
+ *
+ * });
+ *
+ * </pre>
+ *
+ * @param {*} fns... any number of functions which will be injected using the injector.
+ * @return a method
+ */
window.jasmine && (function(window){
window.inject = function (){
var blockFns = Array.prototype.slice.call(arguments, 0);
diff --git a/src/apis.js b/src/apis.js
index 08120c99..6f9b1d0a 100644
--- a/src/apis.js
+++ b/src/apis.js
@@ -10,7 +10,7 @@
* that is also assigned to the $$hashKey property of the object.
*
* @param obj
- * @returns {String} hash string such that the same input will have the same hash string.
+ * @returns {string} hash string such that the same input will have the same hash string.
* The resulting string key is in 'type:hashKey' format.
*/
function hashKey(obj) {
diff --git a/src/scenario/Application.js b/src/scenario/Application.js
index e255041b..f4f4b974 100644
--- a/src/scenario/Application.js
+++ b/src/scenario/Application.js
@@ -44,8 +44,8 @@ angular.scenario.Application.prototype.getWindow_ = function() {
*
* @param {string} url The URL. If it begins with a # then only the
* hash of the page is changed.
- * @param {Function} loadFn function($window, $document) Called when frame loads.
- * @param {Function} errorFn function(error) Called if any error when loading.
+ * @param {function()} loadFn function($window, $document) Called when frame loads.
+ * @param {function()} errorFn function(error) Called if any error when loading.
*/
angular.scenario.Application.prototype.navigateTo = function(url, loadFn, errorFn) {
var self = this;
@@ -78,7 +78,7 @@ angular.scenario.Application.prototype.navigateTo = function(url, loadFn, errorF
* Executes a function in the context of the tested application. Will wait
* for all pending angular xhr requests before executing.
*
- * @param {Function} action The callback to execute. function($window, $document)
+ * @param {function()} action The callback to execute. function($window, $document)
* $document is a jQuery wrapped document.
*/
angular.scenario.Application.prototype.executeAction = function(action) {
diff --git a/src/scenario/Describe.js b/src/scenario/Describe.js
index 45a5aa63..4d52e9d5 100644
--- a/src/scenario/Describe.js
+++ b/src/scenario/Describe.js
@@ -45,7 +45,7 @@ angular.scenario.Describe.specId = 0;
/**
* Defines a block to execute before each it or nested describe.
*
- * @param {Function} body Body of the block.
+ * @param {function()} body Body of the block.
*/
angular.scenario.Describe.prototype.beforeEach = function(body) {
this.beforeEachFns.push(body);
@@ -54,7 +54,7 @@ angular.scenario.Describe.prototype.beforeEach = function(body) {
/**
* Defines a block to execute after each it or nested describe.
*
- * @param {Function} body Body of the block.
+ * @param {function()} body Body of the block.
*/
angular.scenario.Describe.prototype.afterEach = function(body) {
this.afterEachFns.push(body);
@@ -64,7 +64,7 @@ angular.scenario.Describe.prototype.afterEach = function(body) {
* Creates a new describe block that's a child of this one.
*
* @param {string} name Name of the block. Appended to the parent block's name.
- * @param {Function} body Body of the block.
+ * @param {function()} body Body of the block.
*/
angular.scenario.Describe.prototype.describe = function(name, body) {
var child = new angular.scenario.Describe(name, this);
@@ -76,7 +76,7 @@ angular.scenario.Describe.prototype.describe = function(name, body) {
* Same as describe() but makes ddescribe blocks the only to run.
*
* @param {string} name Name of the test.
- * @param {Function} body Body of the block.
+ * @param {function()} body Body of the block.
*/
angular.scenario.Describe.prototype.ddescribe = function(name, body) {
var child = new angular.scenario.Describe(name, this);
@@ -94,7 +94,7 @@ angular.scenario.Describe.prototype.xdescribe = angular.noop;
* Defines a test.
*
* @param {string} name Name of the test.
- * @param {Function} vody Body of the block.
+ * @param {function()} vody Body of the block.
*/
angular.scenario.Describe.prototype.it = function(name, body) {
this.its.push({
@@ -112,7 +112,7 @@ angular.scenario.Describe.prototype.it = function(name, body) {
* Same as it() but makes iit tests the only test to run.
*
* @param {string} name Name of the test.
- * @param {Function} body Body of the block.
+ * @param {function()} body Body of the block.
*/
angular.scenario.Describe.prototype.iit = function(name, body) {
this.it.apply(this, arguments);
diff --git a/src/scenario/Future.js b/src/scenario/Future.js
index 598731fa..335dd2bb 100644
--- a/src/scenario/Future.js
+++ b/src/scenario/Future.js
@@ -4,8 +4,8 @@
* A future action in a spec.
*
* @param {string} name of the future action
- * @param {Function} future callback(error, result)
- * @param {Function} Optional. function that returns the file/line number.
+ * @param {function()} future callback(error, result)
+ * @param {function()} Optional. function that returns the file/line number.
*/
angular.scenario.Future = function(name, behavior, line) {
this.name = name;
@@ -19,7 +19,7 @@ angular.scenario.Future = function(name, behavior, line) {
/**
* Executes the behavior of the closure.
*
- * @param {Function} doneFn Callback function(error, result)
+ * @param {function()} doneFn Callback function(error, result)
*/
angular.scenario.Future.prototype.execute = function(doneFn) {
var self = this;
@@ -40,7 +40,7 @@ angular.scenario.Future.prototype.execute = function(doneFn) {
/**
* Configures the future to convert it's final with a function fn(value)
*
- * @param {Function} fn function(value) that returns the parsed value
+ * @param {function()} fn function(value) that returns the parsed value
*/
angular.scenario.Future.prototype.parsedWith = function(fn) {
this.parser = fn;
diff --git a/src/scenario/ObjectModel.js b/src/scenario/ObjectModel.js
index 76e0201a..b4dad1a5 100644
--- a/src/scenario/ObjectModel.js
+++ b/src/scenario/ObjectModel.js
@@ -121,7 +121,7 @@ angular.scenario.ObjectModel = function(runner) {
* Adds a listener for an event.
*
* @param {string} eventName Name of the event to add a handler for
- * @param {Function} listener Function that will be called when event is fired
+ * @param {function()} listener Function that will be called when event is fired
*/
angular.scenario.ObjectModel.prototype.on = function(eventName, listener) {
eventName = eventName.toLowerCase();
diff --git a/src/scenario/Runner.js b/src/scenario/Runner.js
index fba076a8..d71236bd 100644
--- a/src/scenario/Runner.js
+++ b/src/scenario/Runner.js
@@ -61,7 +61,7 @@ angular.scenario.Runner.prototype.on = function(eventName, listener) {
* @see Describe.js
*
* @param {string} name Name of the block
- * @param {Function} body Body of the block
+ * @param {function()} body Body of the block
*/
angular.scenario.Runner.prototype.describe = function(name, body) {
var self = this;
@@ -82,7 +82,7 @@ angular.scenario.Runner.prototype.describe = function(name, body) {
* @see Describe.js
*
* @param {string} name Name of the block
- * @param {Function} body Body of the block
+ * @param {function()} body Body of the block
*/
angular.scenario.Runner.prototype.ddescribe = function(name, body) {
var self = this;
@@ -103,7 +103,7 @@ angular.scenario.Runner.prototype.ddescribe = function(name, body) {
* @see Describe.js
*
* @param {string} name Name of the block
- * @param {Function} body Body of the block
+ * @param {function()} body Body of the block
*/
angular.scenario.Runner.prototype.it = function(name, body) {
this.currentDescribe.it(name, body);
@@ -115,7 +115,7 @@ angular.scenario.Runner.prototype.it = function(name, body) {
* @see Describe.js
*
* @param {string} name Name of the block
- * @param {Function} body Body of the block
+ * @param {function()} body Body of the block
*/
angular.scenario.Runner.prototype.iit = function(name, body) {
this.currentDescribe.iit(name, body);
@@ -127,7 +127,7 @@ angular.scenario.Runner.prototype.iit = function(name, body) {
*
* @see Describe.js
*
- * @param {Function} Callback to execute
+ * @param {function()} Callback to execute
*/
angular.scenario.Runner.prototype.beforeEach = function(body) {
this.currentDescribe.beforeEach(body);
@@ -139,7 +139,7 @@ angular.scenario.Runner.prototype.beforeEach = function(body) {
*
* @see Describe.js
*
- * @param {Function} Callback to execute
+ * @param {function()} Callback to execute
*/
angular.scenario.Runner.prototype.afterEach = function(body) {
this.currentDescribe.afterEach(body);
diff --git a/src/scenario/Scenario.js b/src/scenario/Scenario.js
index 0df74dae..a7979342 100644
--- a/src/scenario/Scenario.js
+++ b/src/scenario/Scenario.js
@@ -13,7 +13,7 @@ angular.scenario = angular.scenario || {};
* Defines a new output format.
*
* @param {string} name the name of the new output format
- * @param {Function} fn function(context, runner) that generates the output
+ * @param {function()} fn function(context, runner) that generates the output
*/
angular.scenario.output = angular.scenario.output || function(name, fn) {
angular.scenario.output[name] = fn;
@@ -29,7 +29,7 @@ angular.scenario.output = angular.scenario.output || function(name, fn) {
* functions.
*
* @param {string} name The name of the statement
- * @param {Function} fn Factory function(), return a function for
+ * @param {function()} fn Factory function(), return a function for
* the statement.
*/
angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
@@ -65,7 +65,7 @@ angular.scenario.dsl = angular.scenario.dsl || function(name, fn) {
* created for you.
*
* @param {string} name The name of the matcher
- * @param {Function} fn The matching function(expected).
+ * @param {function()} fn The matching function(expected).
*/
angular.scenario.matcher = angular.scenario.matcher || function(name, fn) {
angular.scenario.matcher[name] = function(expected) {
@@ -148,8 +148,8 @@ angular.scenario.setUpAndRun = function(config) {
* continueFunction to continute iterating.
*
* @param {Array} list list to iterate over
- * @param {Function} iterator Callback function(value, continueFunction)
- * @param {Function} done Callback function(error, result) called when
+ * @param {function()} iterator Callback function(value, continueFunction)
+ * @param {function()} done Callback function(error, result) called when
* iteration finishes or an error occurs.
*/
function asyncForEach(list, iterator, done) {
diff --git a/src/scenario/SpecRunner.js b/src/scenario/SpecRunner.js
index 0d6274a4..eacf13a8 100644
--- a/src/scenario/SpecRunner.js
+++ b/src/scenario/SpecRunner.js
@@ -18,7 +18,7 @@ angular.scenario.SpecRunner = function() {
* based on the describe nesting.
*
* @param {Object} spec A spec object
- * @param {Function} specDone function that is called when the spec finshes. Function(error, index)
+ * @param {function()} specDone function that is called when the spec finshes. Function(error, index)
*/
angular.scenario.SpecRunner.prototype.run = function(spec, specDone) {
var self = this;
@@ -85,8 +85,8 @@ angular.scenario.SpecRunner.prototype.run = function(spec, specDone) {
* Note: Do not pass line manually. It happens automatically.
*
* @param {string} name Name of the future
- * @param {Function} behavior Behavior of the future
- * @param {Function} line fn() that returns file/line number
+ * @param {function()} behavior Behavior of the future
+ * @param {function()} line fn() that returns file/line number
*/
angular.scenario.SpecRunner.prototype.addFuture = function(name, behavior, line) {
var future = new angular.scenario.Future(name, angular.bind(this, behavior), line);
@@ -100,8 +100,8 @@ angular.scenario.SpecRunner.prototype.addFuture = function(name, behavior, line)
* Note: Do not pass line manually. It happens automatically.
*
* @param {string} name Name of the future
- * @param {Function} behavior Behavior of the future
- * @param {Function} line fn() that returns file/line number
+ * @param {function()} behavior Behavior of the future
+ * @param {function()} line fn() that returns file/line number
*/
angular.scenario.SpecRunner.prototype.addFutureAction = function(name, behavior, line) {
var self = this;
diff --git a/src/scenario/output/Html.js b/src/scenario/output/Html.js
index 1c2216b5..326928d8 100644
--- a/src/scenario/output/Html.js
+++ b/src/scenario/output/Html.js
@@ -160,7 +160,7 @@ angular.scenario.output('html', function(context, runner, model) {
* Add an error to a step.
*
* @param {Object} The JQuery wrapped context
- * @param {Function} fn() that should return the file/line number of the error
+ * @param {function()} fn() that should return the file/line number of the error
* @param {Object} the error.
*/
function addError(context, line, error) {
diff --git a/src/service/exceptionHandler.js b/src/service/exceptionHandler.js
index b0c8e822..c53118b4 100644
--- a/src/service/exceptionHandler.js
+++ b/src/service/exceptionHandler.js
@@ -11,7 +11,7 @@
* the browser console.
*
* In unit tests, if `angular-mocks.js` is loaded, this service is overriden by
- * {@link angular.mock.service.$exceptionHandler mock $exceptionHandler}
+ * {@link angular.module.NG_MOCK.$exceptionHandler mock $exceptionHandler}
*
* @example
*/
diff --git a/src/service/formFactory.js b/src/service/formFactory.js
index 8ba8ce79..5230d45b 100644
--- a/src/service/formFactory.js
+++ b/src/service/formFactory.js
@@ -180,7 +180,7 @@ function $FormFactoryProvider() {
* Upon receiving the `$valid` event from the widget update the `$error`, `$valid` and `$invalid`
* properties of both the widget as well as the from.
*
- * @param {String} validationKey The validation key to be used when updating the `$error` object.
+ * @param {string} validationKey The validation key to be used when updating the `$error` object.
* The validation key is what will allow the template to bind to a specific validation error
* such as `<div ng:show="form.$error.KEY">error for key</div>`.
*/
@@ -194,7 +194,7 @@ function $FormFactoryProvider() {
* Upon receiving the `$invalid` event from the widget update the `$error`, `$valid` and `$invalid`
* properties of both the widget as well as the from.
*
- * @param {String} validationKey The validation key to be used when updating the `$error` object.
+ * @param {string} validationKey The validation key to be used when updating the `$error` object.
* The validation key is what will allow the template to bind to a specific validation error
* such as `<div ng:show="form.$error.KEY">error for key</div>`.
*/
diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js
index 7b28c408..4073f7fb 100644
--- a/test/angular-mocksSpec.js
+++ b/test/angular-mocksSpec.js
@@ -8,95 +8,95 @@ describe('mocks', function() {
}
it('should look like a Date', function() {
- var date = new angular.mock.TzDate(0,0);
+ var date = new angular.module.NG_MOCK.TzDate(0,0);
expect(angular.isDate(date)).toBe(true);
});
it('should take millis as constructor argument', function() {
- expect(new angular.mock.TzDate(0, 0).getTime()).toBe(0);
- expect(new angular.mock.TzDate(0, 1283555108000).getTime()).toBe(1283555108000);
+ expect(new angular.module.NG_MOCK.TzDate(0, 0).getTime()).toBe(0);
+ expect(new angular.module.NG_MOCK.TzDate(0, 1283555108000).getTime()).toBe(1283555108000);
});
it('should take dateString as constructor argument', function() {
- expect(new angular.mock.TzDate(0, '1970-01-01T00:00:00.000Z').getTime()).toBe(0);
- expect(new angular.mock.TzDate(0, '2010-09-03T23:05:08.023Z').getTime()).toBe(1283555108023);
+ expect(new angular.module.NG_MOCK.TzDate(0, '1970-01-01T00:00:00.000Z').getTime()).toBe(0);
+ expect(new angular.module.NG_MOCK.TzDate(0, '2010-09-03T23:05:08.023Z').getTime()).toBe(1283555108023);
});
it('should fake getLocalDateString method', function() {
//0 in -3h
- var t0 = new angular.mock.TzDate(-3, 0);
+ var t0 = new angular.module.NG_MOCK.TzDate(-3, 0);
expect(t0.toLocaleDateString()).toMatch('1970');
//0 in +0h
- var t1 = new angular.mock.TzDate(0, 0);
+ var t1 = new angular.module.NG_MOCK.TzDate(0, 0);
expect(t1.toLocaleDateString()).toMatch('1970');
//0 in +3h
- var t2 = new angular.mock.TzDate(3, 0);
+ var t2 = new angular.module.NG_MOCK.TzDate(3, 0);
expect(t2.toLocaleDateString()).toMatch('1969');
});
it('should fake getHours method', function() {
//0 in -3h
- var t0 = new angular.mock.TzDate(-3, 0);
+ var t0 = new angular.module.NG_MOCK.TzDate(-3, 0);
expect(t0.getHours()).toBe(3);
//0 in +0h
- var t1 = new angular.mock.TzDate(0, 0);
+ var t1 = new angular.module.NG_MOCK.TzDate(0, 0);
expect(t1.getHours()).toBe(0);
//0 in +3h
- var t2 = new angular.mock.TzDate(3, 0);
+ var t2 = new angular.module.NG_MOCK.TzDate(3, 0);
expect(t2.getHours()).toMatch(21);
});
it('should fake getMinutes method', function() {
//0:15 in -3h
- var t0 = new angular.mock.TzDate(-3, minutes(15));
+ var t0 = new angular.module.NG_MOCK.TzDate(-3, minutes(15));
expect(t0.getMinutes()).toBe(15);
//0:15 in -3.25h
- var t0a = new angular.mock.TzDate(-3.25, minutes(15));
+ var t0a = new angular.module.NG_MOCK.TzDate(-3.25, minutes(15));
expect(t0a.getMinutes()).toBe(30);
//0 in +0h
- var t1 = new angular.mock.TzDate(0, minutes(0));
+ var t1 = new angular.module.NG_MOCK.TzDate(0, minutes(0));
expect(t1.getMinutes()).toBe(0);
//0:15 in +0h
- var t1a = new angular.mock.TzDate(0, minutes(15));
+ var t1a = new angular.module.NG_MOCK.TzDate(0, minutes(15));
expect(t1a.getMinutes()).toBe(15);
//0:15 in +3h
- var t2 = new angular.mock.TzDate(3, minutes(15));
+ var t2 = new angular.module.NG_MOCK.TzDate(3, minutes(15));
expect(t2.getMinutes()).toMatch(15);
//0:15 in +3.25h
- var t2a = new angular.mock.TzDate(3.25, minutes(15));
+ var t2a = new angular.module.NG_MOCK.TzDate(3.25, minutes(15));
expect(t2a.getMinutes()).toMatch(0);
});
it('should fake getSeconds method', function() {
//0 in -3h
- var t0 = new angular.mock.TzDate(-3, 0);
+ var t0 = new angular.module.NG_MOCK.TzDate(-3, 0);
expect(t0.getSeconds()).toBe(0);
//0 in +0h
- var t1 = new angular.mock.TzDate(0, 0);
+ var t1 = new angular.module.NG_MOCK.TzDate(0, 0);
expect(t1.getSeconds()).toBe(0);
//0 in +3h
- var t2 = new angular.mock.TzDate(3, 0);
+ var t2 = new angular.module.NG_MOCK.TzDate(3, 0);
expect(t2.getSeconds()).toMatch(0);
});
it('should create a date representing new year in Bratislava', function() {
- var newYearInBratislava = new angular.mock.TzDate(-1, '2009-12-31T23:00:00.000Z');
+ var newYearInBratislava = new angular.module.NG_MOCK.TzDate(-1, '2009-12-31T23:00:00.000Z');
expect(newYearInBratislava.getTimezoneOffset()).toBe(-60);
expect(newYearInBratislava.getFullYear()).toBe(2010);
expect(newYearInBratislava.getMonth()).toBe(0);
@@ -108,7 +108,7 @@ describe('mocks', function() {
it('should delegate all the UTC methods to the original UTC Date object', function() {
//from when created from string
- var date1 = new angular.mock.TzDate(-1, '2009-12-31T23:00:00.000Z');
+ var date1 = new angular.module.NG_MOCK.TzDate(-1, '2009-12-31T23:00:00.000Z');
expect(date1.getUTCFullYear()).toBe(2009);
expect(date1.getUTCMonth()).toBe(11);
expect(date1.getUTCDate()).toBe(31);
@@ -118,7 +118,7 @@ describe('mocks', function() {
//from when created from millis
- var date2 = new angular.mock.TzDate(-1, date1.getTime());
+ var date2 = new angular.module.NG_MOCK.TzDate(-1, date1.getTime());
expect(date2.getUTCFullYear()).toBe(2009);
expect(date2.getUTCMonth()).toBe(11);
expect(date2.getUTCDate()).toBe(31);
@@ -129,7 +129,7 @@ describe('mocks', function() {
it('should throw error when no third param but toString called', function() {
- expect(function() { new angular.mock.TzDate(0,0).toString(); }).
+ expect(function() { new angular.module.NG_MOCK.TzDate(0,0).toString(); }).
toThrow('Method \'toString\' is not implemented in the TzDate mock');
});
});
@@ -290,8 +290,8 @@ describe('mocks', function() {
});
- describe('angular.mock.debug', function(){
- var d = angular.mock.dump;
+ describe('angular.module.NG_MOCK.dump', function(){
+ var d = angular.module.NG_MOCK.dump;
it('should serialize primitive types', function(){
diff --git a/test/matchers.js b/test/matchers.js
index fbe86a5a..e7fd202a 100644
--- a/test/matchers.js
+++ b/test/matchers.js
@@ -95,7 +95,7 @@ beforeEach(function() {
toHaveClass: function(clazz) {
this.message = function() {
- return "Expected '" + angular.mock.dump(this.actual) + "' to have class '" + clazz + "'.";
+ return "Expected '" + angular.module.NG_MOCK.dump(this.actual) + "' to have class '" + clazz + "'.";
};
return this.actual.hasClass ?
this.actual.hasClass(clazz) :
diff --git a/test/scenario/RunnerSpec.js b/test/scenario/RunnerSpec.js
index 15bcc4b0..db47db87 100644
--- a/test/scenario/RunnerSpec.js
+++ b/test/scenario/RunnerSpec.js
@@ -46,8 +46,8 @@ describe('angular.scenario.Runner', function() {
runner.createSpecRunner_ = function(scope) {
return scope.$new(MockSpecRunner);
};
- runner.on('SpecError', angular.mock.rethrow);
- runner.on('StepError', angular.mock.rethrow);
+ runner.on('SpecError', angular.module.NG_MOCK.rethrow);
+ runner.on('StepError', angular.module.NG_MOCK.rethrow);
});
afterEach(function() {
diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js
index d73923a6..c619cf1a 100644
--- a/test/service/cookiesSpec.js
+++ b/test/service/cookiesSpec.js
@@ -3,7 +3,7 @@
describe('$cookies', function() {
beforeEach(inject(function($provide) {
$provide.factory('$browser', function(){
- return angular.extend(new angular.mock.$Browser(), {cookieHash: {preexisting:'oldCookie'}});
+ return angular.extend(new angular.module.NG_MOCK.$Browser(), {cookieHash: {preexisting:'oldCookie'}});
});
}));
diff --git a/test/service/filter/filtersSpec.js b/test/service/filter/filtersSpec.js
index ca510a72..8d05d951 100644
--- a/test/service/filter/filtersSpec.js
+++ b/test/service/filter/filtersSpec.js
@@ -187,10 +187,10 @@ describe('filters', function() {
describe('date', function() {
- var morning = new angular.mock.TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am
- var noon = new angular.mock.TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm
- var midnight = new angular.mock.TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am
- var earlyDate = new angular.mock.TzDate(+5, '0001-09-03T05:05:08.000Z');
+ var morning = new angular.module.NG_MOCK.TzDate(+5, '2010-09-03T12:05:08.000Z'); //7am
+ var noon = new angular.module.NG_MOCK.TzDate(+5, '2010-09-03T17:05:08.000Z'); //12pm
+ var midnight = new angular.module.NG_MOCK.TzDate(+5, '2010-09-03T05:05:08.000Z'); //12am
+ var earlyDate = new angular.module.NG_MOCK.TzDate(+5, '0001-09-03T05:05:08.000Z');
var date;
diff --git a/test/service/logSpec.js b/test/service/logSpec.js
index ee250b66..e81ac851 100644
--- a/test/service/logSpec.js
+++ b/test/service/logSpec.js
@@ -13,7 +13,7 @@ describe('$log', function() {
$window = {};
logger = '';
$provide.service('$log', $LogProvider);
- $provide.value('$exceptionHandler', angular.mock.rethrow);
+ $provide.value('$exceptionHandler', angular.module.NG_MOCK.rethrow);
$provide.value('$window', $window);
}));
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index b2bcb519..83851289 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -174,10 +174,12 @@ function isCssVisible(node) {
}
function assertHidden(node) {
- assertFalse("Node should be hidden but vas visible: " + angular.mock.dump(node), isCssVisible(node));
+ assertFalse("Node should be hidden but vas visible: " +
+ angular.module.NG_MOCK.dump(node), isCssVisible(node));
}
function assertVisible(node) {
- assertTrue("Node should be visible but vas hidden: " + angular.mock.dump(node), isCssVisible(node));
+ assertTrue("Node should be visible but vas hidden: " +
+ angular.module.NG_MOCK.dump(node), isCssVisible(node));
}