mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
Fix https://github.com/Microsoft/TypeScript/issues/9395: Rename angularjs to angular
This commit is contained in:
@@ -0,0 +1,232 @@
|
||||
# AngularJS Definitions Usage Notes
|
||||
|
||||
## Referencing AngularJS definition files in your code
|
||||
|
||||
To do that, simply add `` at the top of your code.
|
||||
|
||||
That will make available to your code all interfaces AngularJS' main module **ng** implements, as well as the **AUTO** module.
|
||||
|
||||
If you are including other AngularJS' modules in your code, like **ngResource**, just like you needed to include the additional module implementation file in your code, _angular-resource.js_, you will also need to reference the definitions file related to that module. Your code would then have the following definitions files reference:
|
||||
|
||||
|
||||
|
||||
|
||||
Having these modules in separated files is actually good because they sometimes either augment or modify some of **ng**'s interfaces, and thus those differences should only be available to you when you really need them. Also, it forces you to explicit what you're going to be using.
|
||||
|
||||
The following extra definition files are available for referencing:
|
||||
|
||||
* angular-resource.d.ts (for the **ngResource** module)
|
||||
* angular-route.d.ts (for the **ngRoute** module)
|
||||
* angular-cookies.d.ts (for the **ngCookies** module)
|
||||
* angular-sanitize.d.ts (for the **ngSanitize** module)
|
||||
* angular-animate.d.ts (for the **ngAnimate** module)
|
||||
* angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules)
|
||||
|
||||
(postfix with version number for specific verion, eg. angular-resource-1.0.d.ts)
|
||||
|
||||
## The Angular Static
|
||||
|
||||
The definitions declare the AngularJS static variable `angular` as ambient. That means that, after referencing the AngularJS definition, you will be able to get type checks and code assistance for the global `angular` member.
|
||||
|
||||
|
||||
## Definitions modularized
|
||||
|
||||
To avoid cluttering the list of suggestions as you type in your IDE, all interfaces reside in their respective module namespace:
|
||||
|
||||
* `ng` for AngularJS' **ng** module
|
||||
* `ng.auto` for **AUTO**
|
||||
* `ng.cookies` for **ngCookies**
|
||||
* `ng.mock` for **ngMock**
|
||||
* `ng.resource` for **ngResource**
|
||||
* `ng.route` for **ngRoute**
|
||||
* `ng.sanitize` for **ngSanitize**
|
||||
* `ng.animate` for **ngAnimate**
|
||||
|
||||
**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces.
|
||||
|
||||
Below is an example of how to use the interfaces:
|
||||
```ts
|
||||
function MainController($scope: ng.IScope, $http: ng.IHttpService) {
|
||||
// code assistance will now be available for $scope and $http
|
||||
}
|
||||
```
|
||||
|
||||
## Services and other injectables
|
||||
|
||||
AngularJS makes vast use of what it calls "injectable" functions. To put it simple, in AngularJS you are constantly annotating your functions and constructors with their dependencies, services that are going to be provided as arguments automagically during invocation.
|
||||
|
||||
All known services interfaces have been defined, and were named using the following convention:
|
||||
|
||||
**I + 'ServiceName' + 'Service'**
|
||||
|
||||
So, for instance, the **$parse** service has it's interface defined as **ng.IParseService**.
|
||||
|
||||
Service providers, by the same logic, follow this convention:
|
||||
|
||||
**I + 'ServiceName' + 'Provider'**
|
||||
|
||||
The **$httpProvider**, thus, is defined by **ng.IHttpProvider**.
|
||||
|
||||
|
||||
## A word on $scope and assigning new members
|
||||
|
||||
TypeScript allows for static checking. Among other obvious things, that means you're gonna have to extend interfaces when you need to augment an object whose interface has been defined, because otherwise the compiler will see it as an error to try to assign a value to a unspecified member.
|
||||
|
||||
Consider the following ordinary code:
|
||||
```ts
|
||||
function Controller($scope) {
|
||||
$scope.$broadcast('myEvent');
|
||||
$scope.title = 'Yabadabadu';
|
||||
}
|
||||
```
|
||||
That will not produce any compilation error because the compiler does not know the first thing about $scope to do any checking. For that same reason, you will not get any assistance either.
|
||||
|
||||
Now consider this:
|
||||
```ts
|
||||
function Controller($scope: ng.IScope) {
|
||||
$scope.$broadcast('myEvent');
|
||||
$scope.title = 'Yabadabadu';
|
||||
}
|
||||
```
|
||||
|
||||
Now we annotated `$scope` with the interface `ng.IScope`. The compiler now knows that, among other members, `$scope` has a method called `$broadcast`. That interface, however, does not define a `title` property. The compiler will complain about it.
|
||||
|
||||
Since you are augmenting the $scope object, you should let the compiler know what to expect then:
|
||||
```ts
|
||||
interface ICustomScope extends ng.IScope {
|
||||
title: string;
|
||||
}
|
||||
|
||||
function Controller($scope: ICustomScope) {
|
||||
$scope.$broadcast('myEvent');
|
||||
$scope.title = 'Yabadabadu';
|
||||
}
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Working with $resource
|
||||
```ts
|
||||
|
||||
|
||||
|
||||
// We have the option to define arguments for a custom resource
|
||||
interface IArticleParameters {
|
||||
id: number;
|
||||
}
|
||||
|
||||
interface IArticleResource extends ng.resource.IResource<IArticleResource> {
|
||||
title: string;
|
||||
text: string;
|
||||
date: Date;
|
||||
author: number;
|
||||
|
||||
// Although all actions defined on IArticleResourceClass are avaiable with
|
||||
// the '$' prefix, we have the choice to expose only what we will use
|
||||
$publish(): IArticleResource;
|
||||
$unpublish(): IArticleResource;
|
||||
}
|
||||
|
||||
// Let's define a custom resource
|
||||
interface IArticleResourceClass extends ng.resource.IResourceClass<IArticleResource> {
|
||||
// Overload get to accept our custom parameters
|
||||
get(): ng.resource.IResource;
|
||||
get(params: IArticleParameters, onSuccess: Function): IArticleResource;
|
||||
|
||||
// Add our custom resource actions
|
||||
publish(): IArticleResource;
|
||||
publish(params: IArticleParameters): IArticleResource;
|
||||
unpublish(params: IArticleParameters): IArticleResource;
|
||||
}
|
||||
|
||||
function MainController($resource: ng.resource.IResourceService) {
|
||||
|
||||
// IntelliSense will provide IActionDescriptor interface and will validate
|
||||
// your assignment against it
|
||||
var publishDescriptor: ng.resource.IActionDescriptor;
|
||||
publishDescriptor = {
|
||||
method: 'GET',
|
||||
isArray: false
|
||||
};
|
||||
|
||||
// I could still create a descriptor without the interface...
|
||||
var unpublishDescriptor = {
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
// A call to the $resource service returns a IResourceClass. Since
|
||||
// our own IArticleResourceClass defines 2 more actions, we cast the return
|
||||
// value to make the compiler aware of that
|
||||
var articleResource = $resource<IArticleResource, IArticleResourceClass>('/articles/:id', null, {
|
||||
publish : publishDescriptor,
|
||||
unpublish : unpublishDescriptor
|
||||
});
|
||||
|
||||
// Now we can do this
|
||||
articleResource.unpublish({ id: 1 });
|
||||
|
||||
// IResourceClass.get() will be automatically available here
|
||||
var article: IArticleResource = articleResource.get({id: 1}, function success() {
|
||||
// Again, default + custom action here...
|
||||
article.title = 'New Title';
|
||||
article.$save();
|
||||
article.$publish();
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
### Working with $resource in angular-1.0 definitions
|
||||
```ts
|
||||
|
||||
|
||||
|
||||
// Let's define a custom resource
|
||||
interface IArticleResourceClass extends ng.resource.IResourceClass {
|
||||
publish: ng.resource.IActionCall;
|
||||
unpublish: ng.resource.IActionCall;
|
||||
}
|
||||
interface IArticleResource extends ng.resource.IResource {
|
||||
title: string;
|
||||
text: string;
|
||||
date: Date;
|
||||
author: number;
|
||||
$publish: ng.resource.IActionCall;
|
||||
$unpublish: ng.resource.IActionCall;
|
||||
}
|
||||
|
||||
function MainController($resource: ng.resource.IResourceService) {
|
||||
|
||||
// IntelliSense will provide IActionDescriptor interface and will validate
|
||||
// your assignment against it
|
||||
var publishDescriptor: ng.resource.IActionDescriptor;
|
||||
publishDescriptor = {
|
||||
method: 'GET',
|
||||
isArray: false
|
||||
};
|
||||
|
||||
// I could still create a descriptor without the interface...
|
||||
var unpublishDescriptor = {
|
||||
method: 'POST'
|
||||
}
|
||||
|
||||
// A call to the $resource service returns a IResourceClass. Since
|
||||
// our own IArticleResourceClass defines 2 more actions, we cast the return
|
||||
// value to make the compiler aware of that
|
||||
var articles = <IArticleResourceClass> $resource('/articles/:id', null, {
|
||||
publish : publishDescriptor,
|
||||
unpublish : unpublishDescriptor
|
||||
});
|
||||
|
||||
// Now we can do this
|
||||
articles.unpublish({ id: 1 });
|
||||
|
||||
// IResourceClass.get() will be automatically available here
|
||||
var article = <IArticleResource> articles.get({id: 1});
|
||||
|
||||
// Again, default + custom action here...
|
||||
article.title = 'New Title';
|
||||
article.$save();
|
||||
article.$publish();
|
||||
|
||||
}
|
||||
```
|
||||
Vendored
+298
@@ -0,0 +1,298 @@
|
||||
// Type definitions for Angular JS 1.5 (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "angular-animate" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
/**
|
||||
* ngAnimate module (angular-animate.js)
|
||||
*/
|
||||
declare namespace angular.animate {
|
||||
interface IAnimateFactory {
|
||||
(...args: any[]): IAnimateCallbackObject;
|
||||
}
|
||||
|
||||
interface IAnimateCallbackObject {
|
||||
eventFn?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
setClass?: (element: IAugmentedJQuery, addedClasses: string, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
addClass?: (element: IAugmentedJQuery, addedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
removeClass?: (element: IAugmentedJQuery, removedClasses: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
enter?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
leave?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
move?: (element: IAugmentedJQuery, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
animate?: (element: IAugmentedJQuery, fromStyles: string, toStyles: string, doneFunction: Function, options: IAnimationOptions) => any;
|
||||
}
|
||||
|
||||
interface IAnimationPromise extends IPromise<void> {}
|
||||
|
||||
/**
|
||||
* AnimateService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
|
||||
*/
|
||||
interface IAnimateService {
|
||||
/**
|
||||
* Sets up an event listener to fire whenever the animation event has fired on the given element or among any of its children.
|
||||
*
|
||||
* @param event the animation event that will be captured (e.g. enter, leave, move, addClass, removeClass, etc...)
|
||||
* @param container the container element that will capture each of the animation events that are fired on itself as well as among its children
|
||||
* @param callback the callback function that will be fired when the listener is triggered
|
||||
*/
|
||||
on(event: string, container: JQuery, callback: Function): void;
|
||||
|
||||
/**
|
||||
* Deregisters an event listener based on the event which has been associated with the provided element.
|
||||
*
|
||||
* @param event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
|
||||
* @param container the container element the event listener was placed on
|
||||
* @param callback the callback function that was registered as the listener
|
||||
*/
|
||||
off(event: string, container?: JQuery, callback?: Function): void;
|
||||
|
||||
/**
|
||||
* Associates the provided element with a host parent element to allow the element to be animated even if it exists outside of the DOM structure of the Angular application.
|
||||
*
|
||||
* @param element the external element that will be pinned
|
||||
* @param parentElement the host parent element that will be associated with the external element
|
||||
*/
|
||||
pin(element: JQuery, parentElement: JQuery): void;
|
||||
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(element: JQuery, value?: boolean): boolean;
|
||||
enabled(value: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Cancels the provided animation.
|
||||
*/
|
||||
cancel(animationPromise: IAnimationPromise): void;
|
||||
|
||||
/**
|
||||
* Performs an inline animation on the element.
|
||||
*
|
||||
* @param element the element that will be the focus of the animation
|
||||
* @param from a collection of CSS styles that will be applied to the element at the start of the animation
|
||||
* @param to a collection of CSS styles that the element will animate towards
|
||||
* @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate')
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
leave(element: JQuery, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
addClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IAnimationPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateProvider
|
||||
* see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
|
||||
*/
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: IAnimateFactory): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Angular Animation Options
|
||||
* see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation
|
||||
*/
|
||||
interface IAnimationOptions {
|
||||
/**
|
||||
* The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
|
||||
*/
|
||||
to?: Object;
|
||||
|
||||
/**
|
||||
* The starting CSS styles (a key/value object) that will be applied at the start of the animation.
|
||||
*/
|
||||
from?: Object;
|
||||
|
||||
/**
|
||||
* The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and
|
||||
* ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when
|
||||
* spaces are used as a separator. (Note that this will not perform any DOM operation.)
|
||||
*/
|
||||
event?: string;
|
||||
|
||||
/**
|
||||
* The CSS easing value that will be applied to the transition or keyframe animation (or both).
|
||||
*/
|
||||
easing?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS transition style that will be used (e.g. 1s linear all).
|
||||
*/
|
||||
transition?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear).
|
||||
*/
|
||||
keyframe?: string;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be added to the element and spread across the animation.
|
||||
*/
|
||||
addClass?: string;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be removed from the element and spread across
|
||||
* the animation.
|
||||
*/
|
||||
removeClass?: string;
|
||||
|
||||
/**
|
||||
* A number value representing the total duration of the transition and/or keyframe (note that a value
|
||||
* of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely.
|
||||
*/
|
||||
duration?: number;
|
||||
|
||||
/**
|
||||
* A number value representing the total delay of the transition and/or keyframe (note that a value of
|
||||
* 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be
|
||||
* mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be
|
||||
* transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to
|
||||
* all share the same CSS delay value.
|
||||
*/
|
||||
delay?: number;
|
||||
|
||||
/**
|
||||
* A numeric time value representing the delay between successively animated elements (Click here to
|
||||
* learn how CSS-based staggering works in ngAnimate.)
|
||||
*/
|
||||
stagger?: number;
|
||||
|
||||
/**
|
||||
* The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item
|
||||
* in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms)
|
||||
* applyClassesEarly - Whether or not the classes being added or removed will be used when detecting the animation.
|
||||
* This is set by $animate when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time.
|
||||
* (Note that this will prevent any transitions from occuring on the classes being added and removed.)
|
||||
*/
|
||||
staggerIndex?: number;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunner {
|
||||
/**
|
||||
* Starts the animation
|
||||
*
|
||||
* @returns The animation runner with a done function for supplying a callback.
|
||||
*/
|
||||
start(): IAnimateCssRunnerStart;
|
||||
|
||||
/**
|
||||
* Ends (aborts) the animation
|
||||
*/
|
||||
end(): void;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunnerStart extends IPromise<void> {
|
||||
/**
|
||||
* Allows you to add done callbacks to the running animation
|
||||
*
|
||||
* @param callbackFn: the callback function to be run
|
||||
*/
|
||||
done(callbackFn: (animationFinished: boolean) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateCssService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animateCss
|
||||
*/
|
||||
interface IAnimateCssService {
|
||||
(element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner;
|
||||
}
|
||||
}
|
||||
|
||||
declare module angular {
|
||||
interface IModule {
|
||||
animation(name: string, animationFactory: angular.animate.IAnimateFactory): IModule;
|
||||
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
animation(object: Object): IModule;
|
||||
}
|
||||
|
||||
}
|
||||
+430
@@ -0,0 +1,430 @@
|
||||
// Type definitions for Angular JS 1.5 component router
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: David Reher <http://github.com/davidreher>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare namespace angular {
|
||||
/**
|
||||
* `Instruction` is a tree of {@link ComponentInstruction}s with all the information needed
|
||||
* to transition each component in the app to a given route, including all auxiliary routes.
|
||||
*
|
||||
* `Instruction`s can be created using {@link Router#generate}, and can be used to
|
||||
* perform route changes with {@link Router#navigateByInstruction}.
|
||||
*
|
||||
* ### Example
|
||||
*
|
||||
* ```
|
||||
* import {Component} from 'angular2/core';
|
||||
* import {bootstrap} from 'angular2/platform/browser';
|
||||
* import {Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouteConfig} from 'angular2/router';
|
||||
*
|
||||
* @Component({directives: [ROUTER_DIRECTIVES]})
|
||||
* @RouteConfig([
|
||||
* {...},
|
||||
* ])
|
||||
* class AppCmp {
|
||||
* constructor(router: Router) {
|
||||
* var instruction = router.generate(['/MyRoute']);
|
||||
* router.navigateByInstruction(instruction);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* bootstrap(AppCmp, ROUTER_PROVIDERS);
|
||||
* ```
|
||||
*/
|
||||
interface Instruction {
|
||||
component: ComponentInstruction;
|
||||
child: Instruction;
|
||||
auxInstruction: {[key: string]: Instruction};
|
||||
|
||||
urlPath(): string;
|
||||
|
||||
urlParams(): string[];
|
||||
|
||||
specificity(): number;
|
||||
|
||||
resolveComponent(): IPromise<ComponentInstruction>;
|
||||
|
||||
/**
|
||||
* converts the instruction into a URL string
|
||||
*/
|
||||
toRootUrl(): string;
|
||||
|
||||
toUrlQuery(): string;
|
||||
|
||||
/**
|
||||
* Returns a new instruction that shares the state of the existing instruction, but with
|
||||
* the given child {@link Instruction} replacing the existing child.
|
||||
*/
|
||||
replaceChild(child: Instruction): Instruction;
|
||||
|
||||
/**
|
||||
* If the final URL for the instruction is ``
|
||||
*/
|
||||
toUrlPath(): string;
|
||||
|
||||
/**
|
||||
* default instructions override these
|
||||
*/
|
||||
toLinkUrl(): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A router outlet is a placeholder that Angular dynamically fills based on the application's route.
|
||||
*
|
||||
* ## Use
|
||||
*
|
||||
* ```
|
||||
* <router-outlet></router-outlet>
|
||||
* ```
|
||||
*/
|
||||
interface RouterOutlet {
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Called by the Router to instantiate a new component during the commit phase of a navigation.
|
||||
* This method in turn is responsible for calling the `routerOnActivate` hook of its child.
|
||||
*/
|
||||
activate(nextInstruction: ComponentInstruction): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Called by the {@link Router} during the commit phase of a navigation when an outlet
|
||||
* reuses a component between different routes.
|
||||
* This method in turn is responsible for calling the `routerOnReuse` hook of its child.
|
||||
*/
|
||||
reuse(nextInstruction: ComponentInstruction): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Called by the {@link Router} when an outlet disposes of a component's contents.
|
||||
* This method in turn is responsible for calling the `routerOnDeactivate` hook of its child.
|
||||
*/
|
||||
deactivate(nextInstruction: ComponentInstruction): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Called by the {@link Router} during recognition phase of a navigation.
|
||||
*
|
||||
* If this resolves to `false`, the given navigation is cancelled.
|
||||
*
|
||||
* This method delegates to the child component's `routerCanDeactivate` hook if it exists,
|
||||
* and otherwise resolves to true.
|
||||
*/
|
||||
routerCanDeactivate(nextInstruction: ComponentInstruction): IPromise<boolean>;
|
||||
|
||||
/**
|
||||
* Called by the {@link Router} during recognition phase of a navigation.
|
||||
*
|
||||
* If the new child component has a different Type than the existing child component,
|
||||
* this will resolve to `false`. You can't reuse an old component when the new component
|
||||
* is of a different Type.
|
||||
*
|
||||
* Otherwise, this method delegates to the child component's `routerCanReuse` hook if it exists,
|
||||
* or resolves to true if the hook is not present.
|
||||
*/
|
||||
routerCanReuse(nextInstruction: ComponentInstruction): IPromise<boolean>;
|
||||
}
|
||||
|
||||
interface RouteRegistry {
|
||||
/**
|
||||
* Given a component and a configuration object, add the route to this registry
|
||||
*/
|
||||
config(parentComponent: any, config: RouteDefinition): void;
|
||||
|
||||
/**
|
||||
* Reads the annotations of a component and configures the registry based on them
|
||||
*/
|
||||
configFromComponent(component: any): void;
|
||||
|
||||
/**
|
||||
* Given a URL and a parent component, return the most specific instruction for navigating
|
||||
* the application into the state specified by the url
|
||||
*/
|
||||
recognize(url: string, ancestorInstructions: Instruction[]): IPromise<Instruction>;
|
||||
|
||||
/**
|
||||
* Given a normalized list with component names and params like: `['user', {id: 3 }]`
|
||||
* generates a url with a leading slash relative to the provided `parentComponent`.
|
||||
*
|
||||
* If the optional param `_aux` is `true`, then we generate starting at an auxiliary
|
||||
* route boundary.
|
||||
*/
|
||||
generate(linkParams: any[], ancestorInstructions: Instruction[], _aux?: boolean): Instruction;
|
||||
|
||||
hasRoute(name: string, parentComponent: any): boolean;
|
||||
|
||||
generateDefault(componentCursor: any): Instruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* The `Router` is responsible for mapping URLs to components.
|
||||
*
|
||||
* You can see the state of the router by inspecting the read-only field `router.navigating`.
|
||||
* This may be useful for showing a spinner, for instance.
|
||||
*
|
||||
* ## Concepts
|
||||
*
|
||||
* Routers and component instances have a 1:1 correspondence.
|
||||
*
|
||||
* The router holds reference to a number of {@link RouterOutlet}.
|
||||
* An outlet is a placeholder that the router dynamically fills in depending on the current URL.
|
||||
*
|
||||
* When the router navigates from a URL, it must first recognize it and serialize it into an
|
||||
* `Instruction`.
|
||||
* The router uses the `RouteRegistry` to get an `Instruction`.
|
||||
*/
|
||||
interface Router {
|
||||
navigating: boolean;
|
||||
lastNavigationAttempt: string;
|
||||
registry: RouteRegistry;
|
||||
parent: Router;
|
||||
hostComponent: any;
|
||||
|
||||
/**
|
||||
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
|
||||
* component.
|
||||
*/
|
||||
childRouter(hostComponent: any): Router;
|
||||
|
||||
/**
|
||||
* Constructs a child router. You probably don't need to use this unless you're writing a reusable
|
||||
* component.
|
||||
*/
|
||||
auxRouter(hostComponent: any): Router;
|
||||
|
||||
/**
|
||||
* Register an outlet to be notified of primary route changes.
|
||||
*
|
||||
* You probably don't need to use this unless you're writing a reusable component.
|
||||
*/
|
||||
registerPrimaryOutlet(outlet: RouterOutlet): IPromise<boolean>;
|
||||
|
||||
/**
|
||||
* Register an outlet to notified of auxiliary route changes.
|
||||
*
|
||||
* You probably don't need to use this unless you're writing a reusable component.
|
||||
*/
|
||||
registerAuxOutlet(outlet: RouterOutlet): IPromise<boolean>;
|
||||
|
||||
/**
|
||||
* Given an instruction, returns `true` if the instruction is currently active,
|
||||
* otherwise `false`.
|
||||
*/
|
||||
isRouteActive(instruction: Instruction): boolean;
|
||||
|
||||
/**
|
||||
* Dynamically update the routing configuration and trigger a navigation.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
* ```
|
||||
* router.config([
|
||||
* { 'path': '/', 'component': IndexComp },
|
||||
* { 'path': '/user/:id', 'component': UserComp },
|
||||
* ]);
|
||||
* ```
|
||||
*/
|
||||
config(definitions: RouteDefinition[]): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Navigate based on the provided Route Link DSL. It's preferred to navigate with this method
|
||||
* over `navigateByUrl`.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
* This method takes an array representing the Route Link DSL:
|
||||
* ```
|
||||
* ['./MyCmp', {param: 3}]
|
||||
* ```
|
||||
* See the {@link RouterLink} directive for more.
|
||||
*/
|
||||
navigate(linkParams: any[]): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Navigate to a URL. Returns a promise that resolves when navigation is complete.
|
||||
* It's preferred to navigate with `navigate` instead of this method, since URLs are more brittle.
|
||||
*
|
||||
* If the given URL begins with a `/`, router will navigate absolutely.
|
||||
* If the given URL does not begin with `/`, the router will navigate relative to this component.
|
||||
*/
|
||||
navigateByUrl(url: string, _skipLocationChange?: boolean): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Navigate via the provided instruction. Returns a promise that resolves when navigation is
|
||||
* complete.
|
||||
*/
|
||||
navigateByInstruction(instruction: Instruction,
|
||||
_skipLocationChange?: boolean): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Updates this router and all descendant routers according to the given instruction
|
||||
*/
|
||||
commit(instruction: Instruction, _skipLocationChange?: boolean): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Subscribe to URL updates from the router
|
||||
*/
|
||||
subscribe(onNext: (value: any) => void): Object;
|
||||
|
||||
/**
|
||||
* Removes the contents of this router's outlet and all descendant outlets
|
||||
*/
|
||||
deactivate(instruction: Instruction): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Given a URL, returns an instruction representing the component graph
|
||||
*/
|
||||
recognize(url: string): IPromise<Instruction>;
|
||||
|
||||
/**
|
||||
* Navigates to either the last URL successfully navigated to, or the last URL requested if the
|
||||
* router has yet to successfully navigate.
|
||||
*/
|
||||
renavigate(): IPromise<any>;
|
||||
|
||||
/**
|
||||
* Generate an `Instruction` based on the provided Route Link DSL.
|
||||
*/
|
||||
generate(linkParams: any[]): Instruction;
|
||||
}
|
||||
|
||||
/**
|
||||
* RouteData is an immutable map of additional data you can configure in your Route.
|
||||
* You can inject RouteData into the constructor of a component to use it.
|
||||
*/
|
||||
interface RouteData {
|
||||
data: {[key: string]: any};
|
||||
get(key: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* A `ComponentInstruction` represents the route state for a single component. An `Instruction` is
|
||||
* composed of a tree of these `ComponentInstruction`s.
|
||||
*
|
||||
* `ComponentInstructions` is a public API. Instances of `ComponentInstruction` are passed
|
||||
* to route lifecycle hooks, like {@link CanActivate}.
|
||||
*
|
||||
* `ComponentInstruction`s are [https://en.wikipedia.org/wiki/Hash_consing](hash consed). You should
|
||||
* never construct one yourself with "new." Instead, rely on {@link Router/RouteRecognizer} to
|
||||
* construct `ComponentInstruction`s.
|
||||
*
|
||||
* You should not modify this object. It should be treated as immutable.
|
||||
*/
|
||||
interface ComponentInstruction {
|
||||
reuse: boolean;
|
||||
routeData: RouteData;
|
||||
urlPath: string;
|
||||
urlParams: string[];
|
||||
data: RouteData;
|
||||
componentType: any;
|
||||
terminal: boolean;
|
||||
specificity: number;
|
||||
params: {[key: string]: any};
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerOnActivate`, which is called by the router at the end of a
|
||||
* successful route navigation.
|
||||
*
|
||||
* For a single component's navigation, only one of either {@link OnActivate} or {@link OnReuse}
|
||||
* will be called depending on the result of {@link CanReuse}.
|
||||
*
|
||||
* The `routerOnActivate` hook is called with two {@link ComponentInstruction}s as parameters, the
|
||||
* first
|
||||
* representing the current route being navigated to, and the second parameter representing the
|
||||
* previous route or `null`.
|
||||
*
|
||||
* If `routerOnActivate` returns a promise, the route change will wait until the promise settles to
|
||||
* instantiate and activate child components.
|
||||
*
|
||||
* ### Example
|
||||
* {@example router/ts/on_activate/on_activate_example.ts region='routerOnActivate'}
|
||||
*/
|
||||
interface OnActivate {
|
||||
$routerOnActivate(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerCanDeactivate`, which is called by the router to determine
|
||||
* if a component can be removed as part of a navigation.
|
||||
*
|
||||
* The `routerCanDeactivate` hook is called with two {@link ComponentInstruction}s as parameters,
|
||||
* the
|
||||
* first representing the current route being navigated to, and the second parameter
|
||||
* representing the previous route.
|
||||
*
|
||||
* If `routerCanDeactivate` returns or resolves to `false`, the navigation is cancelled. If it
|
||||
* returns or
|
||||
* resolves to `true`, then the navigation continues, and the component will be deactivated
|
||||
* (the {@link OnDeactivate} hook will be run) and removed.
|
||||
*
|
||||
* If `routerCanDeactivate` throws or rejects, the navigation is also cancelled.
|
||||
*
|
||||
* ### Example
|
||||
* {@example router/ts/can_deactivate/can_deactivate_example.ts region='routerCanDeactivate'}
|
||||
*/
|
||||
interface CanDeactivate {
|
||||
$routerCanDeactivate(next?: ComponentInstruction, prev?: ComponentInstruction): boolean | IPromise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerOnDeactivate`, which is called by the router before
|
||||
* destroying
|
||||
* a component as part of a route change.
|
||||
*
|
||||
* The `routerOnDeactivate` hook is called with two {@link ComponentInstruction}s as parameters, the
|
||||
* first
|
||||
* representing the current route being navigated to, and the second parameter representing the
|
||||
* previous route.
|
||||
*
|
||||
* If `routerOnDeactivate` returns a promise, the route change will wait until the promise settles.
|
||||
*
|
||||
* ### Example
|
||||
* {@example router/ts/on_deactivate/on_deactivate_example.ts region='routerOnDeactivate'}
|
||||
*/
|
||||
interface OnDeactivate {
|
||||
$routerOnDeactivate(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerCanReuse`, which is called by the router to determine
|
||||
* whether a
|
||||
* component should be reused across routes, or whether to destroy and instantiate a new component.
|
||||
*
|
||||
* The `routerCanReuse` hook is called with two {@link ComponentInstruction}s as parameters, the
|
||||
* first
|
||||
* representing the current route being navigated to, and the second parameter representing the
|
||||
* previous route.
|
||||
*
|
||||
* If `routerCanReuse` returns or resolves to `true`, the component instance will be reused and the
|
||||
* {@link OnDeactivate} hook will be run. If `routerCanReuse` returns or resolves to `false`, a new
|
||||
* component will be instantiated, and the existing component will be deactivated and removed as
|
||||
* part of the navigation.
|
||||
*
|
||||
* If `routerCanReuse` throws or rejects, the navigation will be cancelled.
|
||||
*
|
||||
* ### Example
|
||||
* {@example router/ts/reuse/reuse_example.ts region='reuseCmp'}
|
||||
*/
|
||||
interface CanReuse {
|
||||
$routerCanReuse(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): boolean | IPromise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines route lifecycle method `routerOnReuse`, which is called by the router at the end of a
|
||||
* successful route navigation when {@link CanReuse} is implemented and returns or resolves to true.
|
||||
*
|
||||
* For a single component's navigation, only one of either {@link OnActivate} or {@link OnReuse}
|
||||
* will be called, depending on the result of {@link CanReuse}.
|
||||
*
|
||||
* The `routerOnReuse` hook is called with two {@link ComponentInstruction}s as parameters, the
|
||||
* first
|
||||
* representing the current route being navigated to, and the second parameter representing the
|
||||
* previous route or `null`.
|
||||
*
|
||||
* ### Example
|
||||
* {@example router/ts/reuse/reuse_example.ts region='reuseCmp'}
|
||||
*/
|
||||
interface OnReuse {
|
||||
$routerOnReuse(next?: angular.ComponentInstruction, prev?: angular.ComponentInstruction): any;
|
||||
}
|
||||
}
|
||||
Vendored
+90
@@ -0,0 +1,90 @@
|
||||
// Type definitions for Angular JS 1.4 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Anthony Ciccarello <http://github.com/aciccarello>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
declare module "angular-cookies" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
/**
|
||||
* ngCookies module (angular-cookies.js)
|
||||
*/
|
||||
declare namespace angular.cookies {
|
||||
|
||||
/**
|
||||
* Cookies options
|
||||
* see https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider#defaults
|
||||
*/
|
||||
interface ICookiesOptions {
|
||||
/**
|
||||
* The cookie will be available only for this path and its sub-paths.
|
||||
* By default, this would be the URL that appears in your base tag.
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* The cookie will be available only for this domain and its sub-domains.
|
||||
* For obvious security reasons the user agent will not accept the cookie if the
|
||||
* current domain is not a sub domain or equals to the requested domain.
|
||||
*/
|
||||
domain?: string;
|
||||
/**
|
||||
* String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object
|
||||
* indicating the exact date/time this cookie will expire.
|
||||
*/
|
||||
expires?: string|Date;
|
||||
/**
|
||||
* The cookie will be available only in secured connection.
|
||||
*/
|
||||
secure?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* CookieService
|
||||
* see http://docs.angularjs.org/api/ngCookies.$cookies
|
||||
*/
|
||||
interface ICookiesService {
|
||||
[index: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* CookieStoreService
|
||||
* see http://docs.angularjs.org/api/ngCookies.$cookieStore
|
||||
*/
|
||||
interface ICookiesService {
|
||||
get(key: string): string;
|
||||
getObject(key: string): any;
|
||||
getObject<T>(key: string): T;
|
||||
getAll(): any;
|
||||
put(key: string, value: string, options?: ICookiesOptions): void;
|
||||
putObject(key: string, value: any, options?: ICookiesOptions): void;
|
||||
remove(key: string, options?: ICookiesOptions): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* CookieStoreService DEPRECATED
|
||||
* see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
|
||||
*/
|
||||
interface ICookieStoreService {
|
||||
/**
|
||||
* Returns the value of given cookie key
|
||||
* @param key Id to use for lookup
|
||||
*/
|
||||
get(key: string): any;
|
||||
/**
|
||||
* Sets a value for given cookie key
|
||||
* @param key Id for the value
|
||||
* @param value Value to be stored
|
||||
*/
|
||||
put(key: string, value: any): void;
|
||||
/**
|
||||
* Remove given cookie
|
||||
* @param key Id of the key-value pair to delete
|
||||
*/
|
||||
remove(key: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IAngularStatic
|
||||
///////////////////////////////////////
|
||||
var angular: ng.IAngularStatic;
|
||||
var mock: ng.IMockStatic;
|
||||
|
||||
mock = angular.mock;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IMockStatic
|
||||
///////////////////////////////////////
|
||||
var date: Date;
|
||||
|
||||
mock.dump({ key: 'value' });
|
||||
|
||||
mock.inject(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]);
|
||||
|
||||
// This overload is not documented on the website, but flows from
|
||||
// how the injector works.
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }],
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]);
|
||||
|
||||
mock.module('module1', 'module2');
|
||||
mock.module(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
mock.module({ module1: function () { return 1; } });
|
||||
mock.module.sharedInjector();
|
||||
|
||||
date = mock.TzDate(-7, '2013-1-1T15:00:00Z');
|
||||
date = mock.TzDate(-8, 12345678);
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IExceptionHandlerProvider
|
||||
///////////////////////////////////////
|
||||
var exceptionHandlerProvider: ng.IExceptionHandlerProvider;
|
||||
|
||||
exceptionHandlerProvider.mode('log');
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// ITimeoutService
|
||||
///////////////////////////////////////
|
||||
var timeoutService: ng.ITimeoutService;
|
||||
|
||||
timeoutService.flush();
|
||||
timeoutService.flush(1234);
|
||||
timeoutService.flushNext();
|
||||
timeoutService.flushNext(1234);
|
||||
timeoutService.verifyNoPendingTasks();
|
||||
|
||||
////////////////////////////////////////
|
||||
// IIntervalService
|
||||
////////////////////////////////////////
|
||||
var intervalService: ng.IIntervalService;
|
||||
var intervalServiceTimeActuallyAdvanced: number;
|
||||
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush();
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush(1234);
|
||||
|
||||
///////////////////////////////////////
|
||||
// ILogService, ILogCall
|
||||
///////////////////////////////////////
|
||||
var logService: ng.ILogService;
|
||||
var logCall: ng.ILogCall;
|
||||
var logs: string[];
|
||||
|
||||
logService.assertEmpty();
|
||||
logService.reset();
|
||||
|
||||
logCall = logService.debug;
|
||||
logCall = logService.error;
|
||||
logCall = logService.info;
|
||||
logCall = logService.log;
|
||||
logCall = logService.warn;
|
||||
|
||||
logs = logCall.logs;
|
||||
|
||||
///////////////////////////////////////
|
||||
// ControllerService mock
|
||||
///////////////////////////////////////
|
||||
var $controller: ng.IControllerService;
|
||||
$controller(class TestController {}, {}, {myBinding: 'works!'});
|
||||
$controller(function TestController() {}, {someLocal: 42}, {myBinding: 'works!'});
|
||||
$controller('TestController', {}, {myBinding: 'works!'});
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IComponentControllerService
|
||||
///////////////////////////////////////
|
||||
var $componentController: ng.IComponentControllerService;
|
||||
$componentController<{}, {}>('Test controller', { $scope: <ng.IScope>{} });
|
||||
$componentController<{}, {}>('Test controller', { $scope: <ng.IScope>{}, test: true });
|
||||
$componentController<{}, { test: boolean }>('Test controller', { $scope: <ng.IScope>{} }, { test: true});
|
||||
$componentController<{}, { test?: boolean }>('Test controller', { $scope: <ng.IScope>{} }, {});
|
||||
$componentController<{}, {}>('Test controller', { $scope: <ng.IScope>{} }, {}, 'identity');
|
||||
$componentController<{ cb: () => void }, {}>('Test controller', { $scope: <ng.IScope>{} });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IHttpBackendService
|
||||
///////////////////////////////////////
|
||||
var httpBackendService: ng.IHttpBackendService;
|
||||
var requestHandler: ng.mock.IRequestHandler;
|
||||
|
||||
httpBackendService.flush();
|
||||
httpBackendService.flush(1234);
|
||||
httpBackendService.resetExpectations();
|
||||
httpBackendService.verifyNoOutstandingExpectation();
|
||||
httpBackendService.verifyNoOutstandingRequest();
|
||||
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', (url: string) => { return true; }, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET('http://test.local');
|
||||
requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.expectJSONP(/test.local/);
|
||||
requestHandler = httpBackendService.expectJSONP((url: string) => { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', (url: string) => { return true; }, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET('http://test.local');
|
||||
requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD((url: string) => { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.whenJSONP(/test.local/);
|
||||
requestHandler = httpBackendService.whenJSONP((url: string) => { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data');
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/);
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT((url: string) => { return true; }, { key: 'value' }, { header: 'value' });
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IRequestHandler
|
||||
///////////////////////////////////////
|
||||
var expectedData = { key: 'value'};
|
||||
requestHandler.passThrough();
|
||||
requestHandler.passThrough().passThrough();
|
||||
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']);
|
||||
requestHandler.respond((method, url, data, headers) => [404, 'data', { header: 'value' }, 'responseText']).respond({});
|
||||
requestHandler.respond((method, url, data, headers) => { return [404, { key: 'value' }, { header: 'value' }, 'responseText']; });
|
||||
requestHandler.respond('data');
|
||||
requestHandler.respond('data').respond({});
|
||||
requestHandler.respond(expectedData);
|
||||
requestHandler.respond({ key: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' }, 'responseText');
|
||||
requestHandler.respond(404, 'data');
|
||||
requestHandler.respond(404, 'data').respond({});
|
||||
requestHandler.respond(404, { key: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' }, 'responseText');
|
||||
Vendored
+345
@@ -0,0 +1,345 @@
|
||||
// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Tony Curtis <http://github.com/daltin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as angular from 'angularjs';
|
||||
|
||||
declare module "angular-mocks/ngMock" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
declare module "angular-mocks/ngMockE2E" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
declare module "angular-mocks/ngAnimateMock" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngMock module (angular-mocks.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare module 'angularjs' {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// We reopen it to add the MockStatic definition
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAngularStatic {
|
||||
mock: IMockStatic;
|
||||
}
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
|
||||
interface IInjectStatic {
|
||||
(...fns: Function[]): any;
|
||||
(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
|
||||
strictDi(val?: boolean): void;
|
||||
}
|
||||
|
||||
interface IMockStatic {
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.dump
|
||||
dump(obj: any): string;
|
||||
|
||||
inject: IInjectStatic
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/function/angular.mock.module
|
||||
module: {
|
||||
(...modules: any[]): any;
|
||||
sharedInjector(): void;
|
||||
}
|
||||
|
||||
// see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate
|
||||
TzDate(offset: number, timestamp: number): Date;
|
||||
TzDate(offset: number, timestamp: string): Date;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$exceptionHandler
|
||||
// see https://docs.angularjs.org/api/ngMock/provider/$exceptionHandlerProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IExceptionHandlerProvider extends IServiceProvider {
|
||||
mode(mode: string): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$timeout
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
flush(delay?: number): void;
|
||||
flushNext(expectedDelay?: number): void;
|
||||
verifyNoPendingTasks(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IntervalService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$interval
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IIntervalService {
|
||||
flush(millis?: number): number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$log
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILogService {
|
||||
assertEmpty(): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface ILogCall {
|
||||
logs: string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ControllerService mock
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$controller
|
||||
// This interface extends http://docs.angularjs.org/api/ng.$controller
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IControllerService {
|
||||
// Although the documentation doesn't state this, locals are optional
|
||||
<T>(controllerConstructor: new (...args: any[]) => T, locals?: any, bindings?: any): T;
|
||||
<T>(controllerConstructor: Function, locals?: any, bindings?: any): T;
|
||||
<T>(controllerName: string, locals?: any, bindings?: any): T;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ComponentControllerService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$componentController
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IComponentControllerService {
|
||||
// TBinding is an interface exposed by a component as per John Papa's style guide
|
||||
// https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#accessible-members-up-top
|
||||
<T, TBinding>(componentName: string, locals: { $scope: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see https://docs.angularjs.org/api/ngMock/service/$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
/**
|
||||
* Flushes all pending requests using the trained responses.
|
||||
* @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed.
|
||||
*/
|
||||
flush(count?: number): void;
|
||||
|
||||
/**
|
||||
* Resets all request expectations, but preserves all backend definitions.
|
||||
*/
|
||||
resetExpectations(): void;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
verifyNoOutstandingExpectation(): void;
|
||||
|
||||
/**
|
||||
* Verifies that there are no outstanding requests that need to be flushed.
|
||||
*/
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for DELETE requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for GET requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for HEAD requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object to be compared with the HTTP headers in the request.
|
||||
*/
|
||||
expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for JSONP requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
*/
|
||||
expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for PATCH requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for POST requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new request expectation for PUT requests.
|
||||
* Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param method HTTP method.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for DELETE requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for GET requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for HEAD requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for JSONP requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PATCH requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for POST requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Creates a new backend definition for PUT requests.
|
||||
* Returns an object with respond method that controls how a matched request is handled.
|
||||
* @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
|
||||
* @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
|
||||
* @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
|
||||
*/
|
||||
whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
export module mock {
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using a function to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
|
||||
*/
|
||||
respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param status HTTP status code to add to the response.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
/**
|
||||
* Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
|
||||
* Returns the RequestHandler object for possible overrides.
|
||||
* @param data Data to add to the response.
|
||||
* @param headers Headers object to add to the response.
|
||||
* @param responseText Response text to add to the response.
|
||||
*/
|
||||
respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
|
||||
|
||||
// Available when ngMockE2E is loaded
|
||||
/**
|
||||
* Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
|
||||
*/
|
||||
passThrough(): IRequestHandler;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
|
||||
//declare var module: (...modules: any[]) => any;
|
||||
declare global {
|
||||
export var inject: angular.IInjectStatic;
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
|
||||
|
||||
|
||||
import IHttpPromiseCallbackArg = angular.IHttpPromiseCallbackArg;
|
||||
|
||||
interface IMyData {}
|
||||
interface IMyHttpPromiseCallbackArg extends IHttpPromiseCallbackArg<IMyData> {}
|
||||
interface IMyResource extends angular.resource.IResource<IMyResource> { }
|
||||
interface IMyResourceClass extends angular.resource.IResourceClass<IMyResource> { }
|
||||
|
||||
///////////////////////////////////////
|
||||
// IActionDescriptor
|
||||
///////////////////////////////////////
|
||||
var actionDescriptor: angular.resource.IActionDescriptor;
|
||||
|
||||
angular.injector(['ng']).invoke(function ($cacheFactory: angular.ICacheFactoryService) {
|
||||
actionDescriptor.method = 'method action';
|
||||
actionDescriptor.params = { key: 'value' };
|
||||
actionDescriptor.url = '/api/test-url/';
|
||||
actionDescriptor.isArray = true;
|
||||
actionDescriptor.transformRequest = function () { };
|
||||
actionDescriptor.transformRequest = [function () { }];
|
||||
actionDescriptor.transformResponse = function () { };
|
||||
actionDescriptor.transformResponse = [function () { }];
|
||||
actionDescriptor.headers = { header: 'value' };
|
||||
actionDescriptor.cache = true;
|
||||
actionDescriptor.cache = $cacheFactory('cacheId');
|
||||
actionDescriptor.timeout = 1000;
|
||||
actionDescriptor.withCredentials = true;
|
||||
actionDescriptor.responseType = 'response type';
|
||||
actionDescriptor.interceptor = {
|
||||
response: function<IMyData> () { return <IMyHttpPromiseCallbackArg>{}; },
|
||||
responseError: function () {}
|
||||
};
|
||||
actionDescriptor.cancellable = true;
|
||||
});
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceClass
|
||||
///////////////////////////////////////
|
||||
var resourceClass: IMyResourceClass;
|
||||
var resource: IMyResource;
|
||||
var resourceArray: angular.resource.IResourceArray<IMyResource>;
|
||||
|
||||
resource = resourceClass.delete();
|
||||
resource = resourceClass.delete({ key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, function () { });
|
||||
resource = resourceClass.delete(function () { });
|
||||
resource = resourceClass.delete(function () { }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resource.$promise.then(function(data: IMyResource) {});
|
||||
resource.$cancelRequest();
|
||||
|
||||
resource = resourceClass.get();
|
||||
resource = resourceClass.get({ key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, function () { });
|
||||
resource = resourceClass.get(function () { });
|
||||
resource = resourceClass.get(function () { }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resourceArray = resourceClass.query();
|
||||
resourceArray = resourceClass.query({ key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query(function () { });
|
||||
resourceArray = resourceClass.query(function () { }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resourceArray.push(resource);
|
||||
resourceArray.$promise.then(function(data: angular.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
resource = resourceClass.remove();
|
||||
resource = resourceClass.remove({ key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, function () { });
|
||||
resource = resourceClass.remove(function () { });
|
||||
resource = resourceClass.remove(function () { }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resource = resourceClass.save();
|
||||
resource = resourceClass.save({ key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, function () { });
|
||||
resource = resourceClass.save(function () { });
|
||||
resource = resourceClass.save(function () { }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
var promise : angular.IPromise<IMyResource>;
|
||||
var arrayPromise : angular.IPromise<IMyResource[]>;
|
||||
var json: IMyResource;
|
||||
|
||||
promise = resource.$delete();
|
||||
promise = resource.$delete({ key: 'value' });
|
||||
promise = resource.$delete({ key: 'value' }, function () { });
|
||||
promise = resource.$delete(function () { });
|
||||
promise = resource.$delete(function () { }, function () { });
|
||||
promise = resource.$delete({ key: 'value' }, function () { }, function () { });
|
||||
promise.then(function(data: IMyResource) {});
|
||||
|
||||
promise = resource.$get();
|
||||
promise = resource.$get({ key: 'value' });
|
||||
promise = resource.$get({ key: 'value' }, function () { });
|
||||
promise = resource.$get(function () { });
|
||||
promise = resource.$get(function () { }, function () { });
|
||||
promise = resource.$get({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
arrayPromise = resourceArray[0].$query();
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { }, function () { });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { });
|
||||
arrayPromise.then(function(data: angular.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
promise = resource.$remove();
|
||||
promise = resource.$remove({ key: 'value' });
|
||||
promise = resource.$remove({ key: 'value' }, function () { });
|
||||
promise = resource.$remove(function () { });
|
||||
promise = resource.$remove(function () { }, function () { });
|
||||
promise = resource.$remove({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
promise = resource.$save();
|
||||
promise = resource.$save({ key: 'value' });
|
||||
promise = resource.$save({ key: 'value' }, function () { });
|
||||
promise = resource.$save(function () { });
|
||||
promise = resource.$save(function () { }, function () { });
|
||||
promise = resource.$save({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
json = resource.toJSON();
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceService
|
||||
///////////////////////////////////////
|
||||
var resourceService: angular.resource.IResourceService;
|
||||
resourceClass = resourceService<IMyResource, IMyResourceClass>('test');
|
||||
resourceClass = resourceService<IMyResource>('test');
|
||||
resourceClass = resourceService('test');
|
||||
|
||||
///////////////////////////////////////
|
||||
// IModule
|
||||
///////////////////////////////////////
|
||||
var mod: ng.IModule;
|
||||
var resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction<IMyResource>;
|
||||
var resourceService: angular.resource.IResourceService;
|
||||
|
||||
resourceClass = resourceServiceFactoryFunction<IMyResourceClass>(resourceService);
|
||||
|
||||
resourceServiceFactoryFunction = function (resourceService: angular.resource.IResourceService) { return <any>resourceClass; };
|
||||
mod = mod.factory('factory name', resourceServiceFactoryFunction);
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceServiceProvider
|
||||
///////////////////////////////////////
|
||||
var resourceServiceProvider: angular.resource.IResourceServiceProvider;
|
||||
resourceServiceProvider.defaults.stripTrailingSlashes = false;
|
||||
Vendored
+195
@@ -0,0 +1,195 @@
|
||||
// Type definitions for Angular JS 1.5 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
|
||||
|
||||
declare module 'angular-resource' {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngResource module (angular-resource.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace angular.resource {
|
||||
|
||||
/**
|
||||
* Currently supported options for the $resource factory options argument.
|
||||
*/
|
||||
interface IResourceOptions {
|
||||
/**
|
||||
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
|
||||
*/
|
||||
stripTrailingSlashes?: boolean;
|
||||
/**
|
||||
* If true, the request made by a "non-instance" call will be cancelled (if not already completed) by calling
|
||||
* $cancelRequest() on the call's return value. This can be overwritten per action. (Defaults to false.)
|
||||
*/
|
||||
cancellable?: boolean;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see http://docs.angularjs.org/api/ngResource.$resource
|
||||
// Most part of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
method: string;
|
||||
params?: any;
|
||||
url?: string;
|
||||
isArray?: boolean;
|
||||
transformRequest?: angular.IHttpRequestTransformer | angular.IHttpRequestTransformer[];
|
||||
transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[];
|
||||
headers?: any;
|
||||
cache?: boolean | angular.ICacheObject;
|
||||
/**
|
||||
* Note: In contrast to $http.config, promises are not supported in $resource, because the same value
|
||||
* would be used for multiple requests. If you are looking for a way to cancel requests, you should
|
||||
* use the cancellable option.
|
||||
*/
|
||||
timeout?: number
|
||||
cancellable?: boolean;
|
||||
withCredentials?: boolean;
|
||||
responseType?: string;
|
||||
interceptor?: IHttpInterceptor;
|
||||
}
|
||||
|
||||
// Allow specify more resource methods
|
||||
// No need to add duplicates for all four overloads.
|
||||
interface IResourceMethod<T> {
|
||||
(): T;
|
||||
(params: Object): T;
|
||||
(success: Function, error?: Function): T;
|
||||
(params: Object, success: Function, error?: Function): T;
|
||||
(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
}
|
||||
|
||||
// Allow specify resource moethod which returns the array
|
||||
// No need to add duplicates for all four overloads.
|
||||
interface IResourceArrayMethod<T> {
|
||||
(): IResourceArray<T>;
|
||||
(params: Object): IResourceArray<T>;
|
||||
(success: Function, error?: Function): IResourceArray<T>;
|
||||
(params: Object, success: Function, error?: Function): IResourceArray<T>;
|
||||
(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
//
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
|
||||
//
|
||||
// Only those methods with an HTTP body do have 'data' as first parameter:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
|
||||
// More specifically, those methods are POST, PUT and PATCH:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
|
||||
//
|
||||
// Also, static calls always return the IResource (or IResourceArray) retrieved
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
|
||||
interface IResourceClass<T> {
|
||||
new(dataOrParams? : any) : T;
|
||||
get: IResourceMethod<T>;
|
||||
|
||||
query: IResourceArrayMethod<T>;
|
||||
|
||||
save: IResourceMethod<T>;
|
||||
|
||||
remove: IResourceMethod<T>;
|
||||
|
||||
delete: IResourceMethod<T>;
|
||||
}
|
||||
|
||||
// Instance calls always return the the promise of the request which retrieved the object
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
|
||||
interface IResource<T> {
|
||||
$get(): angular.IPromise<T>;
|
||||
$get(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$get(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$query(): angular.IPromise<IResourceArray<T>>;
|
||||
$query(params?: Object, success?: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
$query(success: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
|
||||
$save(): angular.IPromise<T>;
|
||||
$save(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$save(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$remove(): angular.IPromise<T>;
|
||||
$remove(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$remove(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$delete(): angular.IPromise<T>;
|
||||
$delete(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$delete(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$cancelRequest(): void;
|
||||
|
||||
/** the promise of the original server interaction that created this instance. **/
|
||||
$promise : angular.IPromise<T>;
|
||||
$resolved : boolean;
|
||||
toJSON(): T;
|
||||
}
|
||||
|
||||
/**
|
||||
* Really just a regular Array object with $promise and $resolve attached to it
|
||||
*/
|
||||
interface IResourceArray<T> extends Array<T & IResource<T>> {
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : angular.IPromise<IResourceArray<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction<T> {
|
||||
($resource: angular.resource.IResourceService): IResourceClass<T>;
|
||||
<U extends IResourceClass<T>>($resource: angular.resource.IResourceService): U;
|
||||
}
|
||||
|
||||
// IResourceServiceProvider used to configure global settings
|
||||
interface IResourceServiceProvider extends angular.IServiceProvider {
|
||||
|
||||
defaults: IResourceOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** extensions to base ng based on using angular-resource */
|
||||
declare namespace angular {
|
||||
|
||||
interface IModule {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction<any>): IModule;
|
||||
}
|
||||
}
|
||||
|
||||
interface Array<T>
|
||||
{
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : angular.IPromise<Array<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @license HTTP Auth Interceptor Module for AngularJS
|
||||
* (c) 2013 Jonathan Park @ Daptiv Solutions Inc
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
declare var $routeProvider: ng.route.IRouteProvider;
|
||||
$routeProvider
|
||||
.when('/projects/:projectId/dashboard', {
|
||||
controller: 'I am a string',
|
||||
templateUrl: "So am I",
|
||||
caseInsensitiveMatch: true,
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.when('/projects/:projectId/dashboard2', {
|
||||
controller: function () {
|
||||
//Look at me - I'm a function!
|
||||
},
|
||||
template: function ($routeParams?: ng.route.IRouteParamsService) {
|
||||
return "I return a string"
|
||||
}
|
||||
})
|
||||
.when('/projects/:projectId/dashboard3', {
|
||||
controllerAs: 'I am a string',
|
||||
template: "Yup. String"
|
||||
})
|
||||
.when('/projects/:projectId/dashboard4', {
|
||||
controller: 'I am a string',
|
||||
templateUrl: function ($routeParams?: ng.route.IRouteParamsService) {
|
||||
return "I return a string"
|
||||
}
|
||||
})
|
||||
.when('/projects/:projectId/dashboard5', {
|
||||
controller: ['$log',function($log:ng.ILogService){
|
||||
$log.info('I am array')
|
||||
}],
|
||||
templateUrl: function ($routeParams?: ng.route.IRouteParamsService) {
|
||||
return "I return a string"
|
||||
}
|
||||
})
|
||||
.otherwise({ redirectTo: '/' })
|
||||
.otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" });
|
||||
|
||||
|
||||
var current: ng.route.ICurrentRoute;
|
||||
current.locals['test-key'] = 'test-value';
|
||||
Vendored
+158
@@ -0,0 +1,158 @@
|
||||
// Type definitions for Angular JS 1.3 (ngRoute module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Jonathan Park <https://github.com/park9140>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare module "angular-route" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngRoute module (angular-route.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace angular.route {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteParamsService
|
||||
// see http://docs.angularjs.org/api/ngRoute.$routeParams
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteParamsService {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteService
|
||||
// see http://docs.angularjs.org/api/ngRoute.$route
|
||||
// see http://docs.angularjs.org/api/ngRoute.$routeProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteService {
|
||||
reload(): void;
|
||||
routes: any;
|
||||
|
||||
// May not always be available. For instance, current will not be available
|
||||
// to a controller that was not initialized as a result of a route maching.
|
||||
current?: ICurrentRoute;
|
||||
|
||||
/**
|
||||
* Causes $route service to update the current URL, replacing current route parameters with those specified in newParams.
|
||||
* Provided property names that match the route's path segment definitions will be interpolated into the
|
||||
* location's path, while remaining properties will be treated as query params.
|
||||
*
|
||||
* @param newParams Object.<string, string> mapping of URL parameter names to values
|
||||
*/
|
||||
updateParams(newParams:{[key:string]:string}): void;
|
||||
|
||||
}
|
||||
|
||||
type InlineAnnotatedFunction = Function|Array<string|Function>
|
||||
|
||||
/**
|
||||
* see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation
|
||||
*/
|
||||
interface IRoute {
|
||||
/**
|
||||
* {(string|function()=}
|
||||
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
|
||||
*/
|
||||
controller?: string|InlineAnnotatedFunction;
|
||||
/**
|
||||
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
|
||||
*/
|
||||
controllerAs?: string;
|
||||
/**
|
||||
* Undocumented?
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
|
||||
*
|
||||
* If template is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
template?: string|{($routeParams?: angular.route.IRouteParamsService) : string;}
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Path or function that returns a path to an html template that should be used by ngView.
|
||||
*
|
||||
* If templateUrl is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
templateUrl?: string|{ ($routeParams?: angular.route.IRouteParamsService): string; }
|
||||
/**
|
||||
* {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
|
||||
*
|
||||
* - key - {string}: a name of a dependency to be injected into the controller.
|
||||
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
|
||||
*/
|
||||
resolve?: {[key: string]: any};
|
||||
/**
|
||||
* {(string|function())=}
|
||||
* Value to update $location path with and trigger route redirection.
|
||||
*
|
||||
* If redirectTo is a function, it will be called with the following parameters:
|
||||
*
|
||||
* - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
|
||||
* - {string} - current $location.path()
|
||||
* - {Object} - current $location.search()
|
||||
* - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
|
||||
*/
|
||||
redirectTo?: string|{($routeParams?: angular.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) : string};
|
||||
/**
|
||||
* Reload route when only $location.search() or $location.hash() changes.
|
||||
*
|
||||
* This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
|
||||
*/
|
||||
reloadOnSearch?: boolean;
|
||||
/**
|
||||
* Match routes without being case sensitive
|
||||
*
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
}
|
||||
|
||||
// see http://docs.angularjs.org/api/ng.$route#current
|
||||
interface ICurrentRoute extends IRoute {
|
||||
locals: {
|
||||
[index: string]: any;
|
||||
$scope: IScope;
|
||||
$template: string;
|
||||
};
|
||||
|
||||
params: any;
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
/**
|
||||
* Match routes without being case sensitive
|
||||
*
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
/**
|
||||
* Sets route definition that will be used on route change when no other route definition is matched.
|
||||
*
|
||||
* @params Mapping information to be assigned to $route.current.
|
||||
*/
|
||||
otherwise(params: IRoute): IRouteProvider;
|
||||
/**
|
||||
* Adds a new route definition to the $route service.
|
||||
*
|
||||
* @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
|
||||
*
|
||||
* - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain optional named groups with a question mark: e.g.:name?.
|
||||
*
|
||||
* For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
|
||||
*
|
||||
* @param route Mapping information to be assigned to $route.current on route match.
|
||||
*/
|
||||
when(path: string, route: IRoute): IRouteProvider;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
var shouldBeString: string;
|
||||
|
||||
declare var $sanitizeService: ng.sanitize.ISanitizeService;
|
||||
shouldBeString = $sanitizeService(shouldBeString);
|
||||
|
||||
declare var $linky: ng.sanitize.filter.ILinky;
|
||||
shouldBeString = $linky(shouldBeString);
|
||||
shouldBeString = $linky(shouldBeString, shouldBeString);
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// Type definitions for Angular JS 1.3 (ngSanitize module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
declare module "angular-sanitize" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngSanitize module (angular-sanitize.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace angular.sanitize {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SanitizeService
|
||||
// see http://docs.angularjs.org/api/ngSanitize.$sanitize
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ISanitizeService {
|
||||
(html: string): string;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Filters included with the ngSanitize
|
||||
// see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
export module filter {
|
||||
|
||||
// Finds links in text input and turns them into html links.
|
||||
// Supports http/https/ftp/mailto and plain email address links.
|
||||
// see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky
|
||||
interface ILinky {
|
||||
(text: string, target?: string): string;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+1934
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,219 @@
|
||||
|
||||
|
||||
// issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/369
|
||||
https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js
|
||||
/**
|
||||
* @license HTTP Auth Interceptor Module for AngularJS
|
||||
* (c) 2012 Witold Szczerba
|
||||
* License: MIT
|
||||
*/
|
||||
angular.module('http-auth-interceptor', [])
|
||||
|
||||
.provider('authService', function () {
|
||||
/**
|
||||
* Holds all the requests which failed due to 401 response,
|
||||
* so they can be re-requested in future, once login is completed.
|
||||
*/
|
||||
var buffer = [];
|
||||
|
||||
/**
|
||||
* Required by HTTP interceptor.
|
||||
* Function is attached to provider to be invisible for regular users of this service.
|
||||
*/
|
||||
this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
buffer.push({
|
||||
config: config,
|
||||
deferred: deferred
|
||||
});
|
||||
}
|
||||
|
||||
this.$get = ['$rootScope', '$injector', <any>function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
|
||||
var $http: ng.IHttpService; //initialized later because of circular dependency problem
|
||||
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
$http = $http || $injector.get('$http');
|
||||
$http(config).then(function (response) {
|
||||
deferred.resolve(response);
|
||||
});
|
||||
}
|
||||
function retryAll() {
|
||||
for (var i = 0; i < buffer.length; ++i) {
|
||||
retry(buffer[i].config, buffer[i].deferred);
|
||||
}
|
||||
buffer = [];
|
||||
}
|
||||
|
||||
return {
|
||||
loginConfirmed: function () {
|
||||
$rootScope.$broadcast('event:auth-loginConfirmed');
|
||||
retryAll();
|
||||
}
|
||||
}
|
||||
}]
|
||||
})
|
||||
|
||||
/**
|
||||
* $http interceptor.
|
||||
* On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
|
||||
*/
|
||||
.config(['$httpProvider', 'authServiceProvider', <any>function ($httpProvider: ng.IHttpProvider, authServiceProvider) {
|
||||
|
||||
var interceptor = ['$rootScope', '$q', <any>function ($rootScope: ng.IScope, $q: ng.IQService) {
|
||||
function success(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
return response;
|
||||
}
|
||||
|
||||
function error(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
if (response.status === 401) {
|
||||
var deferred = $q.defer<void>();
|
||||
authServiceProvider.pushToBuffer(response.config, deferred);
|
||||
$rootScope.$broadcast('event:auth-loginRequired');
|
||||
return deferred.promise;
|
||||
}
|
||||
// otherwise
|
||||
return $q.reject(response);
|
||||
}
|
||||
|
||||
return function (promise: ng.IHttpPromise<any>) {
|
||||
return promise.then(success, error);
|
||||
}
|
||||
|
||||
}];
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
}]);
|
||||
|
||||
|
||||
namespace HttpAndRegularPromiseTests {
|
||||
interface Person {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
interface ExpectedResponse extends Person { }
|
||||
|
||||
interface SomeControllerScope extends ng.IScope {
|
||||
person: Person;
|
||||
theAnswer: number;
|
||||
letters: string[];
|
||||
}
|
||||
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
$http.get("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would NOT type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
var aPromise: ng.IPromise<Person> = $q.when({ firstName: "Jack", lastName: "Sparrow" });
|
||||
aPromise.then((person: Person) => {
|
||||
$scope.person = person;
|
||||
});
|
||||
|
||||
var bPromise: ng.IPromise<number> = $q.when(42);
|
||||
bPromise.then((answer: number) => {
|
||||
$scope.theAnswer = answer;
|
||||
});
|
||||
|
||||
var cPromise: ng.IPromise<string[]> = $q.when(["a", "b", "c"]);
|
||||
cPromise.then((letters: string[]) => {
|
||||
$scope.letters = letters;
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
var anotherController: Function = ($scope: SomeControllerScope, $http:
|
||||
ng.IHttpService, $q: ng.IQService) => {
|
||||
|
||||
var buildFooData: Function = () => 42;
|
||||
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback<ExpectedResponse>) => {
|
||||
$http.get('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
|
||||
doFoo((data) => console.log(data));
|
||||
}
|
||||
}
|
||||
|
||||
// Test for AngularJS Syntax
|
||||
|
||||
namespace My.Namespace {
|
||||
export var x; // need to export something for module to kick in
|
||||
}
|
||||
|
||||
// IModule Registering Test
|
||||
var mod = angular.module('tests', []);
|
||||
mod.controller('name', function ($scope: ng.IScope) { })
|
||||
mod.controller('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.controller(My.Namespace);
|
||||
mod.directive('name', <any>function ($scope: ng.IScope) { })
|
||||
mod.directive('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.directive(My.Namespace);
|
||||
mod.factory('name', function ($scope: ng.IScope) { })
|
||||
mod.factory('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.factory(My.Namespace);
|
||||
mod.filter('name', function ($scope: ng.IScope) { })
|
||||
mod.filter('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.filter(My.Namespace);
|
||||
mod.provider('name', function ($scope: ng.IScope) { })
|
||||
mod.provider('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.provider(My.Namespace);
|
||||
mod.service('name', function ($scope: ng.IScope) { })
|
||||
mod.service('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.service(My.Namespace);
|
||||
mod.constant('name', 23);
|
||||
mod.constant('name', "23");
|
||||
mod.constant(My.Namespace);
|
||||
mod.value('name', 23);
|
||||
mod.value('name', "23");
|
||||
mod.value(My.Namespace);
|
||||
|
||||
// Promise signature tests
|
||||
var foo: ng.IPromise<number>;
|
||||
foo.then((x) => {
|
||||
// x is inferred to be a number
|
||||
return "asdf";
|
||||
}).then((x) => {
|
||||
// x is inferred to be string
|
||||
x.length;
|
||||
return 123;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number
|
||||
x.toFixed();
|
||||
return;
|
||||
}).then((x) => {
|
||||
// x is infered to be void
|
||||
// Typescript will prevent you to actually use x as a local variable
|
||||
// Try object:
|
||||
return { a: 123 };
|
||||
}).then((x) => {
|
||||
// Object is inferred here
|
||||
x.a = 123;
|
||||
//Try a promise
|
||||
var y: ng.IPromise<number>;
|
||||
return y;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number, which is the resolved value of a promise
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
|
||||
// angular.element() tests
|
||||
var element = angular.element("div.myApp");
|
||||
var scope: ng.IScope = element.scope();
|
||||
|
||||
|
||||
Vendored
+760
@@ -0,0 +1,760 @@
|
||||
// Type definitions for Angular JS 1.0
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare var angular: ng.IAngularStatic;
|
||||
|
||||
// Support for painless dependency injection
|
||||
interface Function {
|
||||
$inject:string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ng module (angular.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng {
|
||||
|
||||
// All service providers extend this interface
|
||||
interface IServiceProvider {
|
||||
$get(): any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// see http://docs.angularjs.org/api
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAngularStatic {
|
||||
bind(context: any, fn: Function, ...args: any[]): Function;
|
||||
bootstrap(element: string, modules?: any[]): auto.IInjectorService;
|
||||
bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService;
|
||||
bootstrap(element: Element, modules?: any[]): auto.IInjectorService;
|
||||
bootstrap(element: Document, modules?: any[]): auto.IInjectorService;
|
||||
copy(source: any, destination?: any): any;
|
||||
element: IAugmentedJQueryStatic;
|
||||
equals(value1: any, value2: any): boolean;
|
||||
extend(destination: any, ...sources: any[]): any;
|
||||
forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any;
|
||||
fromJson(json: string): any;
|
||||
identity(arg?: any): any;
|
||||
injector(modules?: any[]): auto.IInjectorService;
|
||||
isArray(value: any): boolean;
|
||||
isDate(value: any): boolean;
|
||||
isDefined(value: any): boolean;
|
||||
isElement(value: any): boolean;
|
||||
isFunction(value: any): boolean;
|
||||
isNumber(value: any): boolean;
|
||||
isObject(value: any): boolean;
|
||||
isString(value: any): boolean;
|
||||
isUndefined(value: any): boolean;
|
||||
lowercase(str: string): string;
|
||||
/** construct your angular application
|
||||
official docs: Interface for configuring angular modules.
|
||||
see: http://docs.angularjs.org/api/angular.Module
|
||||
*/
|
||||
module(
|
||||
/** name of your module you want to create */
|
||||
name: string,
|
||||
/** name of modules yours depends on */
|
||||
requires?: string[],
|
||||
configFunction?: any): IModule;
|
||||
noop(...args: any[]): void;
|
||||
toJson(obj: any, pretty?: boolean): string;
|
||||
uppercase(str: string): string;
|
||||
version: {
|
||||
full: string;
|
||||
major: number;
|
||||
minor: number;
|
||||
dot: number;
|
||||
codename: string;
|
||||
};
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Module
|
||||
// see http://docs.angularjs.org/api/angular.Module
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IModule {
|
||||
animation(name: string, animationFactory: Function): IModule;
|
||||
animation(name: string, inlineAnnotadedFunction: any[]): IModule;
|
||||
animation(object: Object): IModule;
|
||||
/** configure existing services.
|
||||
Use this method to register work which needs to be performed on module loading
|
||||
*/
|
||||
config(configFn: Function): IModule;
|
||||
/** configure existing services.
|
||||
Use this method to register work which needs to be performed on module loading
|
||||
*/
|
||||
config(inlineAnnotadedFunction: any[]): IModule;
|
||||
constant(name: string, value: any): IModule;
|
||||
constant(object: Object): IModule;
|
||||
controller(name: string, controllerConstructor: Function): IModule;
|
||||
controller(name: string, inlineAnnotadedConstructor: any[]): IModule;
|
||||
controller(object : Object): IModule;
|
||||
directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule;
|
||||
directive(name: string, inlineAnnotadedFunction: any[]): IModule;
|
||||
directive(object: Object): IModule;
|
||||
factory(name: string, serviceFactoryFunction: Function): IModule;
|
||||
factory(name: string, inlineAnnotadedFunction: any[]): IModule;
|
||||
factory(object: Object): IModule;
|
||||
filter(name: string, filterFactoryFunction: Function): IModule;
|
||||
filter(name: string, inlineAnnotadedFunction: any[]): IModule;
|
||||
filter(object: Object): IModule;
|
||||
provider(name: string, serviceProviderConstructor: Function): IModule;
|
||||
provider(name: string, inlineAnnotadedConstructor: any[]): IModule;
|
||||
provider(object: Object): IModule;
|
||||
run(initializationFunction: Function): IModule;
|
||||
run(inlineAnnotadedFunction: any[]): IModule;
|
||||
service(name: string, serviceConstructor: Function): IModule;
|
||||
service(name: string, inlineAnnotadedConstructor: any[]): IModule;
|
||||
service(object: Object): IModule;
|
||||
value(name: string, value: any): IModule;
|
||||
value(object: Object): IModule;
|
||||
|
||||
// Properties
|
||||
name: string;
|
||||
requires: string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Attributes
|
||||
// see http://docs.angularjs.org/api/ng.$compile.directive.Attributes
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAttributes {
|
||||
$set(name: string, value: any): void;
|
||||
$observe(name: string, fn:(value?:any)=>any):void;
|
||||
$attr: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// FormController
|
||||
// see http://docs.angularjs.org/api/ng.directive:form.FormController
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IFormController {
|
||||
$pristine: boolean;
|
||||
$dirty: boolean;
|
||||
$valid: boolean;
|
||||
$invalid: boolean;
|
||||
$error: any;
|
||||
$setDirty(): void;
|
||||
$setPristine(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// NgModelController
|
||||
// see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface INgModelController {
|
||||
$render(): void;
|
||||
$setValidity(validationErrorKey: string, isValid: boolean): void;
|
||||
$setViewValue(value: string): void;
|
||||
|
||||
// XXX Not sure about the types here. Documentation states it's a string, but
|
||||
// I've seen it receiving other types throughout the code.
|
||||
// Falling back to any for now.
|
||||
$viewValue: any;
|
||||
|
||||
// XXX Same as avove
|
||||
$modelValue: any;
|
||||
|
||||
$parsers: IModelParser[];
|
||||
$formatters: IModelFormatter[];
|
||||
$error: any;
|
||||
$pristine: boolean;
|
||||
$dirty: boolean;
|
||||
$valid: boolean;
|
||||
$invalid: boolean;
|
||||
}
|
||||
|
||||
interface IModelParser {
|
||||
(value: any): any;
|
||||
}
|
||||
|
||||
interface IModelFormatter {
|
||||
(value: any): any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Scope
|
||||
// see http://docs.angularjs.org/api/ng.$rootScope.Scope
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IScope {
|
||||
$apply(): any;
|
||||
$apply(exp: string): any;
|
||||
$apply(exp: (scope: IScope) => any): any;
|
||||
|
||||
$broadcast(name: string, ...args: any[]): IAngularEvent;
|
||||
$destroy(): void;
|
||||
$digest(): void;
|
||||
$emit(name: string, ...args: any[]): IAngularEvent;
|
||||
|
||||
// Documentation says exp is optional, but actual implementaton counts on it
|
||||
$eval(expression: string): any;
|
||||
$eval(expression: (scope: IScope) => any): any;
|
||||
|
||||
// Documentation says exp is optional, but actual implementaton counts on it
|
||||
$evalAsync(expression: string): void;
|
||||
$evalAsync(expression: (scope: IScope) => any): void;
|
||||
|
||||
// Defaults to false by the implementation checking strategy
|
||||
$new(isolate?: boolean): IScope;
|
||||
|
||||
$on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function;
|
||||
|
||||
$watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function;
|
||||
$watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
|
||||
$watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function;
|
||||
$watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function;
|
||||
|
||||
$watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
$watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function;
|
||||
|
||||
$parent: IScope;
|
||||
|
||||
$id: number;
|
||||
|
||||
// Hidden members
|
||||
$$isolateBindings: any;
|
||||
$$phase: any;
|
||||
}
|
||||
|
||||
interface IAngularEvent {
|
||||
targetScope: IScope;
|
||||
currentScope: IScope;
|
||||
name: string;
|
||||
preventDefault: Function;
|
||||
defaultPrevented: boolean;
|
||||
|
||||
// Available only events that were $emit-ted
|
||||
stopPropagation?: Function;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WindowService
|
||||
// see http://docs.angularjs.org/api/ng.$window
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IWindowService extends Window {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// BrowserService
|
||||
// TODO undocumented, so we need to get it from the source code
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IBrowserService {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
// see http://docs.angularjs.org/api/ng.$timeout
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
(func: Function, delay?: number, invokeApply?: boolean): IPromise<any>;
|
||||
cancel(promise: IPromise<any>): boolean;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// FilterService
|
||||
// see http://docs.angularjs.org/api/ng.$filter
|
||||
// see http://docs.angularjs.org/api/ng.$filterProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IFilterService {
|
||||
(name: string): Function;
|
||||
}
|
||||
|
||||
interface IFilterProvider extends IServiceProvider {
|
||||
register(name: string, filterFactory: Function): IServiceProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LocaleService
|
||||
// see http://docs.angularjs.org/api/ng.$locale
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILocaleService {
|
||||
id: string;
|
||||
|
||||
// These are not documented
|
||||
// Check angular's i18n files for exemples
|
||||
NUMBER_FORMATS: ILocaleNumberFormatDescriptor;
|
||||
DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor;
|
||||
pluralCat: (num: any) => string;
|
||||
}
|
||||
|
||||
interface ILocaleNumberFormatDescriptor {
|
||||
DECIMAL_SEP: string;
|
||||
GROUP_SEP: string;
|
||||
PATTERNS: ILocaleNumberPatternDescriptor[];
|
||||
CURRENCY_SYM: string;
|
||||
}
|
||||
|
||||
interface ILocaleNumberPatternDescriptor {
|
||||
minInt: number;
|
||||
minFrac: number;
|
||||
maxFrac: number;
|
||||
posPre: string;
|
||||
posSuf: string;
|
||||
negPre: string;
|
||||
negSuf: string;
|
||||
gSize: number;
|
||||
lgSize: number;
|
||||
}
|
||||
|
||||
interface ILocaleDateTimeFormatDescriptor {
|
||||
MONTH: string[];
|
||||
SHORTMONTH: string[];
|
||||
DAY: string[];
|
||||
SHORTDAY: string[];
|
||||
AMPMS: string[];
|
||||
medium: string;
|
||||
short: string;
|
||||
fullDate: string;
|
||||
longDate: string;
|
||||
mediumDate: string;
|
||||
shortDate: string;
|
||||
mediumTime: string;
|
||||
shortTime: string;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
// see http://docs.angularjs.org/api/ng.$log
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILogService {
|
||||
debug: ILogCall;
|
||||
error: ILogCall;
|
||||
info: ILogCall;
|
||||
log: ILogCall;
|
||||
warn: ILogCall;
|
||||
}
|
||||
|
||||
// We define this as separete interface so we can reopen it later for
|
||||
// the ngMock module.
|
||||
interface ILogCall {
|
||||
(...args: any[]): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ParseService
|
||||
// see http://docs.angularjs.org/api/ng.$parse
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IParseService {
|
||||
(expression: string): ICompiledExpression;
|
||||
}
|
||||
|
||||
interface ICompiledExpression {
|
||||
(context: any, locals?: any): any;
|
||||
|
||||
// If value is not provided, undefined is gonna be used since the implementation
|
||||
// does not check the parameter. Let's force a value for consistency. If consumer
|
||||
// whants to undefine it, pass the undefined value explicitly.
|
||||
assign(context: any, value: any): any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LocationService
|
||||
// see http://docs.angularjs.org/api/ng.$location
|
||||
// see http://docs.angularjs.org/api/ng.$locationProvider
|
||||
// see http://docs.angularjs.org/guide/dev_guide.services.$location
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILocationService {
|
||||
absUrl(): string;
|
||||
hash(): string;
|
||||
hash(newHash: string): ILocationService;
|
||||
host(): string;
|
||||
path(): string;
|
||||
path(newPath: string): ILocationService;
|
||||
port(): number;
|
||||
protocol(): string;
|
||||
replace(): ILocationService;
|
||||
search(): any;
|
||||
search(parametersMap: any): ILocationService;
|
||||
search(parameter: string, parameterValue: any): ILocationService;
|
||||
url(): string;
|
||||
url(url: string): ILocationService;
|
||||
}
|
||||
|
||||
interface ILocationProvider extends IServiceProvider {
|
||||
hashPrefix(): string;
|
||||
hashPrefix(prefix: string): ILocationProvider;
|
||||
html5Mode(): boolean;
|
||||
|
||||
// Documentation states that parameter is string, but
|
||||
// implementation tests it as boolean, which makes more sense
|
||||
// since this is a toggler
|
||||
html5Mode(active: boolean): ILocationProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DocumentService
|
||||
// see http://docs.angularjs.org/api/ng.$document
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IDocumentService extends Document {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
// see http://docs.angularjs.org/api/ng.$exceptionHandler
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IExceptionHandlerService {
|
||||
(exception: Error, cause?: string): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RootElementService
|
||||
// see http://docs.angularjs.org/api/ng.$rootElement
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRootElementService extends JQuery {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// QService
|
||||
// see http://docs.angularjs.org/api/ng.$q
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IQService {
|
||||
all(promises: IPromise<any>[]): IPromise<any[]>;
|
||||
defer<T>(): IDeferred<T>;
|
||||
reject(reason?: any): IPromise<void>;
|
||||
when<T>(value: T): IPromise<T>;
|
||||
}
|
||||
|
||||
interface IPromise<T> {
|
||||
then<TResult>(successCallback: (promiseValue: T) => IHttpPromise<TResult>, errorCallback?: (reason: any) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>, errorCallback?: (reason: any) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IDeferred<T> {
|
||||
resolve(value?: T): void;
|
||||
reject(reason?: any): void;
|
||||
promise: IPromise<T>;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AnchorScrollService
|
||||
// see http://docs.angularjs.org/api/ng.$anchorScroll
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnchorScrollService {
|
||||
(): void;
|
||||
}
|
||||
|
||||
interface IAnchorScrollProvider extends IServiceProvider {
|
||||
disableAutoScrolling(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CacheFactoryService
|
||||
// see http://docs.angularjs.org/api/ng.$cacheFactory
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICacheFactoryService {
|
||||
// Lets not foce the optionsMap to have the capacity member. Even though
|
||||
// it's the ONLY option considered by the implementation today, a consumer
|
||||
// might find it useful to associate some other options to the cache object.
|
||||
//(cacheId: string, optionsMap?: { capacity: number; }): CacheObject;
|
||||
(cacheId: string, optionsMap?: { capacity: number; }): ICacheObject;
|
||||
|
||||
// Methods bellow are not documented
|
||||
info(): any;
|
||||
get (cacheId: string): ICacheObject;
|
||||
}
|
||||
|
||||
interface ICacheObject {
|
||||
info(): {
|
||||
id: string;
|
||||
size: number;
|
||||
|
||||
// Not garanteed to have, since it's a non-mandatory option
|
||||
//capacity: number;
|
||||
};
|
||||
put(key: string, value?: any): void;
|
||||
get (key: string): any;
|
||||
remove(key: string): void;
|
||||
removeAll(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CompileService
|
||||
// see http://docs.angularjs.org/api/ng.$compile
|
||||
// see http://docs.angularjs.org/api/ng.$compileProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICompileService {
|
||||
(element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
|
||||
(element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
|
||||
(element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction;
|
||||
}
|
||||
|
||||
interface ICompileProvider extends IServiceProvider {
|
||||
directive(name: string, directiveFactory: Function): ICompileProvider;
|
||||
|
||||
// Undocumented, but it is there...
|
||||
directive(directivesMap: any): ICompileProvider;
|
||||
}
|
||||
|
||||
interface ITemplateLinkingFunction {
|
||||
// Let's hint but not force cloneAttachFn's signature
|
||||
(scope: IScope, cloneAttachFn?: (clonedElement?: JQuery, scope?: IScope) => any): JQuery;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ControllerService
|
||||
// see http://docs.angularjs.org/api/ng.$controller
|
||||
// see http://docs.angularjs.org/api/ng.$controllerProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IControllerService {
|
||||
// Although the documentation doesn't state this, locals are optional
|
||||
(controllerConstructor: Function, locals?: any): any;
|
||||
(controllerName: string, locals?: any): any;
|
||||
}
|
||||
|
||||
interface IControllerProvider extends IServiceProvider {
|
||||
register(name: string, controllerConstructor: Function): void;
|
||||
register(name: string, dependencyAnnotadedConstructor: any[]): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpService
|
||||
// see http://docs.angularjs.org/api/ng.$http
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpService {
|
||||
// At least moethod and url must be provided...
|
||||
(config: IRequestConfig): IHttpPromise<any>;
|
||||
get (url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
delete (url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
head(url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
jsonp(url: string, RequestConfig?: any): IHttpPromise<any>;
|
||||
post(url: string, data: any, RequestConfig?: any): IHttpPromise<any>;
|
||||
put(url: string, data: any, RequestConfig?: any): IHttpPromise<any>;
|
||||
defaults: IRequestConfig;
|
||||
|
||||
// For debugging, BUT it is documented as public, so...
|
||||
pendingRequests: any[];
|
||||
}
|
||||
|
||||
// This is just for hinting.
|
||||
// Some opetions might not be available depending on the request.
|
||||
// see http://docs.angularjs.org/api/ng.$http#Usage for options explanations
|
||||
interface IRequestConfig {
|
||||
method: string;
|
||||
url: string;
|
||||
params?: any;
|
||||
|
||||
// XXX it has it's own structure... perhaps we should define it in the future
|
||||
headers?: any;
|
||||
|
||||
cache?: any;
|
||||
timeout?: number;
|
||||
withCredentials?: boolean;
|
||||
|
||||
// These accept multiple types, so let's defile them as any
|
||||
data?: any;
|
||||
transformRequest?: any;
|
||||
transformResponse?: any;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallback<T> {
|
||||
(data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void;
|
||||
}
|
||||
|
||||
interface IHttpPromiseCallbackArg<T> {
|
||||
data?: T;
|
||||
status?: number;
|
||||
headers?: (headerName: string) => string;
|
||||
config?: IRequestConfig;
|
||||
}
|
||||
|
||||
interface IHttpPromise<T> extends IPromise<T> {
|
||||
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
|
||||
error(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IHttpProvider extends IServiceProvider {
|
||||
defaults: IRequestConfig;
|
||||
interceptors: any[];
|
||||
responseInterceptors: any[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see http://docs.angularjs.org/api/ng.$httpBackend
|
||||
// You should never need to use this service directly.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
// XXX Perhaps define callback signature in the future
|
||||
(method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// InterpolateService
|
||||
// see http://docs.angularjs.org/api/ng.$interpolate
|
||||
// see http://docs.angularjs.org/api/ng.$interpolateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IInterpolateService {
|
||||
(text: string, mustHaveExpression?: boolean): IInterpolationFunction;
|
||||
endSymbol(): string;
|
||||
startSymbol(): string;
|
||||
}
|
||||
|
||||
interface IInterpolationFunction {
|
||||
(context: any): string;
|
||||
}
|
||||
|
||||
interface IInterpolateProvider extends IServiceProvider {
|
||||
startSymbol(): string;
|
||||
startSymbol(value: string): IInterpolateProvider;
|
||||
endSymbol(): string;
|
||||
endSymbol(value: string): IInterpolateProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteParamsService
|
||||
// see http://docs.angularjs.org/api/ng.$routeParams
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteParamsService {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TemplateCacheService
|
||||
// see http://docs.angularjs.org/api/ng.$templateCache
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITemplateCacheService extends ICacheObject {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RootScopeService
|
||||
// see http://docs.angularjs.org/api/ng.$rootScope
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRootScopeService extends IScope {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteService
|
||||
// see http://docs.angularjs.org/api/ng.$route
|
||||
// see http://docs.angularjs.org/api/ng.$routeProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteService {
|
||||
reload(): void;
|
||||
routes: any;
|
||||
|
||||
// May not always be available. For instance, current will not be available
|
||||
// to a controller that was not initialized as a result of a route maching.
|
||||
current?: ICurrentRoute;
|
||||
}
|
||||
|
||||
// see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations
|
||||
interface IRoute {
|
||||
controller?: any;
|
||||
name?: string;
|
||||
template?: string;
|
||||
templateUrl?: any;
|
||||
resolve?: any;
|
||||
redirectTo?: any;
|
||||
reloadOnSearch?: boolean;
|
||||
}
|
||||
|
||||
// see http://docs.angularjs.org/api/ng.$route#current
|
||||
interface ICurrentRoute extends IRoute {
|
||||
locals: {
|
||||
$scope: IScope;
|
||||
$template: string;
|
||||
};
|
||||
|
||||
params: any;
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
otherwise(params: any): IRouteProvider;
|
||||
when(path: string, route: IRoute): IRouteProvider;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Directive
|
||||
// see http://docs.angularjs.org/api/ng.$compileProvider#directive
|
||||
// and http://docs.angularjs.org/guide/directive
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
interface IDirective{
|
||||
priority?: number;
|
||||
template?: any;
|
||||
templateUrl?: any;
|
||||
replace?: boolean;
|
||||
transclude?: any;
|
||||
restrict?: string;
|
||||
scope?: any;
|
||||
link?: Function;
|
||||
compile?: Function;
|
||||
controller?: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// angular.element
|
||||
// when calling angular.element, angular returns a jQuery object,
|
||||
// augmented with additional methods like e.g. scope.
|
||||
// see: http://docs.angularjs.org/api/angular.element
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAugmentedJQueryStatic extends JQueryStatic {
|
||||
(selector: string, context?: any): IAugmentedJQuery;
|
||||
(element: Element): IAugmentedJQuery;
|
||||
(object: {}): IAugmentedJQuery;
|
||||
(elementArray: Element[]): IAugmentedJQuery;
|
||||
(object: JQuery): IAugmentedJQuery;
|
||||
(func: Function): IAugmentedJQuery;
|
||||
(array: any[]): IAugmentedJQuery;
|
||||
(): IAugmentedJQuery;
|
||||
}
|
||||
|
||||
interface IAugmentedJQuery extends JQuery {
|
||||
// TODO: events, how to define?
|
||||
//$destroy
|
||||
|
||||
find(selector: string): IAugmentedJQuery;
|
||||
find(element: any): IAugmentedJQuery;
|
||||
find(obj: JQuery): IAugmentedJQuery;
|
||||
|
||||
controller(name: string): any;
|
||||
injector(): any;
|
||||
scope(): IScope;
|
||||
|
||||
inheritedData(key: string, value: any): JQuery;
|
||||
inheritedData(obj: { [key: string]: any; }): JQuery;
|
||||
inheritedData(key?: string): any;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AUTO module (angular.js)
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
export module auto {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// InjectorService
|
||||
// see http://docs.angularjs.org/api/AUTO.$injector
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
interface IInjectorService {
|
||||
annotate(fn: Function): string[];
|
||||
annotate(inlineAnnotadedFunction: any[]): string[];
|
||||
get (name: string): any;
|
||||
instantiate(typeConstructor: Function, locals?: any): any;
|
||||
invoke(func: Function, context?: any, locals?: any): any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// ProvideService
|
||||
// see http://docs.angularjs.org/api/AUTO.$provide
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
interface IProvideService {
|
||||
// Documentation says it returns the registered instance, but actual
|
||||
// implementation does not return anything.
|
||||
// constant(name: string, value: any): any;
|
||||
constant(name: string, value: any): void;
|
||||
|
||||
decorator(name: string, decorator: Function): void;
|
||||
decorator(name: string, decoratorInline: any[]): void;
|
||||
factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider;
|
||||
provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider;
|
||||
provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider;
|
||||
service(name: string, constructor: Function): ng.IServiceProvider;
|
||||
value(name: string, value: any): ng.IServiceProvider;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,571 @@
|
||||
|
||||
|
||||
// issue: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/369
|
||||
// https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js
|
||||
/**
|
||||
* @license HTTP Auth Interceptor Module for AngularJS
|
||||
* (c) 2012 Witold Szczerba
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
class AuthService {
|
||||
/**
|
||||
* Holds all the requests which failed due to 401 response,
|
||||
* so they can be re-requested in future, once login is completed.
|
||||
*/
|
||||
buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred<any>; }[] = [];
|
||||
|
||||
/**
|
||||
* Required by HTTP interceptor.
|
||||
* Function is attached to provider to be invisible for regular users of this service.
|
||||
*/
|
||||
pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
this.buffer.push({
|
||||
config: config,
|
||||
deferred: deferred
|
||||
});
|
||||
}
|
||||
|
||||
$get = [
|
||||
'$rootScope', '$injector', <any>function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) {
|
||||
var $http: ng.IHttpService; //initialized later because of circular dependency problem
|
||||
function retry(config: ng.IRequestConfig, deferred: ng.IDeferred<any>) {
|
||||
$http = $http || $injector.get('$http');
|
||||
$http(config).then(function (response) {
|
||||
deferred.resolve(response);
|
||||
});
|
||||
}
|
||||
function retryAll() {
|
||||
for (var i = 0; i < this.buffer.length; ++i) {
|
||||
retry(this.buffer[i].config, this.buffer[i].deferred);
|
||||
}
|
||||
this.buffer = [];
|
||||
}
|
||||
|
||||
return {
|
||||
loginConfirmed: function () {
|
||||
$rootScope.$broadcast('event:auth-loginConfirmed');
|
||||
retryAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
angular.module('http-auth-interceptor', [])
|
||||
|
||||
.provider('authService', AuthService)
|
||||
|
||||
/**
|
||||
* $http interceptor.
|
||||
* On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'.
|
||||
*/
|
||||
.config(['$httpProvider', 'authServiceProvider', <any>function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) {
|
||||
|
||||
var interceptor = ['$rootScope', '$q', <any>function ($rootScope: ng.IScope, $q: ng.IQService) {
|
||||
function success(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
return response;
|
||||
}
|
||||
|
||||
function error(response: ng.IHttpPromiseCallbackArg<any>) {
|
||||
if (response.status === 401) {
|
||||
var deferred = $q.defer<void>();
|
||||
authServiceProvider.pushToBuffer(response.config, deferred);
|
||||
$rootScope.$broadcast('event:auth-loginRequired');
|
||||
return deferred.promise;
|
||||
}
|
||||
// otherwise
|
||||
return $q.reject(response);
|
||||
}
|
||||
|
||||
return function (promise: ng.IHttpPromise<any>) {
|
||||
return promise.then(success, error);
|
||||
}
|
||||
|
||||
}];
|
||||
$httpProvider.responseInterceptors.push(interceptor);
|
||||
}]);
|
||||
|
||||
|
||||
namespace HttpAndRegularPromiseTests {
|
||||
interface Person {
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
interface ExpectedResponse extends Person { }
|
||||
|
||||
interface SomeControllerScope extends ng.IScope {
|
||||
person: Person;
|
||||
theAnswer: number;
|
||||
letters: string[];
|
||||
snack: string;
|
||||
nothing?: string;
|
||||
}
|
||||
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.success((data: ExpectedResponse) => {
|
||||
$scope.person = data;
|
||||
});
|
||||
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
$http.get<ExpectedResponse>("http://somewhere/some/resource")
|
||||
.then((response: ng.IHttpPromiseCallbackArg<ExpectedResponse>) => {
|
||||
// typing lost, so something like
|
||||
// var i: number = response.data
|
||||
// would NOT type check
|
||||
$scope.person = response.data;
|
||||
});
|
||||
|
||||
var aPromise: ng.IPromise<Person> = $q.when({ firstName: "Jack", lastName: "Sparrow" });
|
||||
aPromise.then((person: Person) => {
|
||||
$scope.person = person;
|
||||
});
|
||||
|
||||
var bPromise: ng.IPromise<number> = $q.when(42);
|
||||
bPromise.then((answer: number) => {
|
||||
$scope.theAnswer = answer;
|
||||
});
|
||||
|
||||
var cPromise: ng.IPromise<string[]> = $q.when(["a", "b", "c"]);
|
||||
cPromise.then((letters: string[]) => {
|
||||
$scope.letters = letters;
|
||||
});
|
||||
|
||||
// When $q.when is passed an IPromise<T>, it returns an IPromise<T>
|
||||
var dPromise: ng.IPromise<string> = $q.when($q.when("ALBATROSS!"));
|
||||
dPromise.then((snack: string) => {
|
||||
$scope.snack = snack;
|
||||
});
|
||||
|
||||
// $q.when may be called without arguments
|
||||
var ePromise: ng.IPromise<void> = $q.when();
|
||||
ePromise.then(() => {
|
||||
$scope.nothing = "really nothing";
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
var anotherController: Function = ($scope: SomeControllerScope, $http:
|
||||
ng.IHttpService, $q: ng.IQService) => {
|
||||
|
||||
var buildFooData: Function = () => 42;
|
||||
|
||||
var doFoo: Function = (callback: ng.IHttpPromiseCallback<ExpectedResponse>) => {
|
||||
$http.get<ExpectedResponse>('/foo', buildFooData())
|
||||
.success(callback);
|
||||
}
|
||||
|
||||
doFoo((data: any) => console.log(data));
|
||||
}
|
||||
}
|
||||
|
||||
// Test for AngularJS Syntax
|
||||
|
||||
namespace My.Namespace {
|
||||
export var x: any; // need to export something for module to kick in
|
||||
}
|
||||
|
||||
// IModule Registering Test
|
||||
var mod = angular.module('tests', []);
|
||||
mod.controller('name', function ($scope: ng.IScope) { })
|
||||
mod.controller('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.controller(My.Namespace);
|
||||
mod.directive('name', <any>function ($scope: ng.IScope) { })
|
||||
mod.directive('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.directive(My.Namespace);
|
||||
mod.factory('name', function ($scope: ng.IScope) { })
|
||||
mod.factory('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.factory(My.Namespace);
|
||||
mod.filter('name', function ($scope: ng.IScope) { })
|
||||
mod.filter('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.filter(My.Namespace);
|
||||
mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } })
|
||||
mod.provider('name', TestProvider);
|
||||
mod.provider('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.provider(My.Namespace);
|
||||
mod.service('name', function ($scope: ng.IScope) { })
|
||||
mod.service('name', ['$scope', <any>function ($scope: ng.IScope) { }])
|
||||
mod.service(My.Namespace);
|
||||
mod.constant('name', 23);
|
||||
mod.constant('name', "23");
|
||||
mod.constant(My.Namespace);
|
||||
mod.value('name', 23);
|
||||
mod.value('name', "23");
|
||||
mod.value(My.Namespace);
|
||||
|
||||
class TestProvider implements ng.IServiceProvider {
|
||||
constructor(private $scope: ng.IScope) {
|
||||
}
|
||||
|
||||
$get() {
|
||||
}
|
||||
}
|
||||
|
||||
// Promise signature tests
|
||||
var foo: ng.IPromise<number>;
|
||||
foo.then((x) => {
|
||||
// x is inferred to be a number
|
||||
return "asdf";
|
||||
}).then((x) => {
|
||||
// x is inferred to be string
|
||||
x.length;
|
||||
return 123;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number
|
||||
x.toFixed();
|
||||
return;
|
||||
}).then((x) => {
|
||||
// x is infered to be void
|
||||
// Typescript will prevent you to actually use x as a local variable
|
||||
// Try object:
|
||||
return { a: 123 };
|
||||
}).then((x) => {
|
||||
// Object is inferred here
|
||||
x.a = 123;
|
||||
//Try a promise
|
||||
var y: ng.IPromise<number>;
|
||||
return y;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number, which is the resolved value of a promise
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
|
||||
var httpFoo: ng.IHttpPromise<number>;
|
||||
httpFoo.then((x) => {
|
||||
// When returning a promise the generic type must be inferred.
|
||||
var innerPromise : ng.IPromise<number>;
|
||||
return innerPromise;
|
||||
}).then((x) => {
|
||||
// must still be number.
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
|
||||
function test_angular_forEach() {
|
||||
var values: { [key: string]: string } = { name: 'misko', gender: 'male' };
|
||||
var log: string[] = [];
|
||||
angular.forEach(values, function (value, key) {
|
||||
this.push(key + ': ' + value);
|
||||
}, log);
|
||||
//expect(log).toEqual(['name: misko', 'gender: male']);
|
||||
}
|
||||
|
||||
// angular.element() tests
|
||||
var element = angular.element("div.myApp");
|
||||
var scope: ng.IScope = element.scope();
|
||||
var isolateScope: ng.IScope = element.isolateScope();
|
||||
|
||||
|
||||
|
||||
function test_IAttributes(attributes: ng.IAttributes){
|
||||
return attributes;
|
||||
}
|
||||
|
||||
test_IAttributes({
|
||||
$addClass: function (classVal){},
|
||||
$removeClass: function(classVal){},
|
||||
$set: function(key, value){},
|
||||
$observe: function(name, fn){
|
||||
return fn;
|
||||
},
|
||||
$attr: {}
|
||||
});
|
||||
|
||||
class SampleDirective implements ng.IDirective {
|
||||
public restrict = 'A';
|
||||
name = 'doh';
|
||||
|
||||
compile(templateElement: ng.IAugmentedJQuery) {
|
||||
return {
|
||||
post: this.link
|
||||
};
|
||||
}
|
||||
|
||||
static instance():ng.IDirective {
|
||||
return new SampleDirective();
|
||||
}
|
||||
|
||||
link(scope: ng.IScope) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class SampleDirective2 implements ng.IDirective {
|
||||
public restrict = 'EAC';
|
||||
|
||||
compile(templateElement: ng.IAugmentedJQuery) {
|
||||
return {
|
||||
pre: this.link
|
||||
};
|
||||
}
|
||||
|
||||
static instance():ng.IDirective {
|
||||
return new SampleDirective2();
|
||||
}
|
||||
|
||||
link(scope: ng.IScope) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance);
|
||||
|
||||
// test from https://docs.angularjs.org/guide/directive
|
||||
angular.module('docsSimpleDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
template: 'Name: {{customer.name}} Address: {{customer.address}}'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsTemplateUrlDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
templateUrl: 'my-customer.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsRestrictDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'my-customer.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsScopeProblemExample', [])
|
||||
.controller('NaomiController', ['$scope', function($scope: any) {
|
||||
$scope.customer = {
|
||||
name: 'Naomi',
|
||||
address: '1600 Amphitheatre'
|
||||
};
|
||||
}])
|
||||
.controller('IgorController', ['$scope', function($scope: any) {
|
||||
$scope.customer = {
|
||||
name: 'Igor',
|
||||
address: '123 Somewhere'
|
||||
};
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
templateUrl: 'my-customer.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsIsolateScopeDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
|
||||
$scope.igor = { name: 'Igor', address: '123 Somewhere' };
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
customerInfo: '=info'
|
||||
},
|
||||
templateUrl: 'my-customer-iso.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsIsolationExample', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
|
||||
$scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' };
|
||||
}])
|
||||
.directive('myCustomer', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: {
|
||||
customerInfo: '=info'
|
||||
},
|
||||
templateUrl: 'my-customer-plus-vojta.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsTimeDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.format = 'M/d/yy h:mm:ss a';
|
||||
}])
|
||||
.directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) {
|
||||
|
||||
return {
|
||||
link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) {
|
||||
var format: any,
|
||||
timeoutId: any;
|
||||
|
||||
function updateTime() {
|
||||
element.text(dateFilter(new Date(), format));
|
||||
}
|
||||
|
||||
scope.$watch(attrs['myCurrentTime'], function (value: any) {
|
||||
format = value;
|
||||
updateTime();
|
||||
});
|
||||
|
||||
element.on('$destroy', function () {
|
||||
$interval.cancel(timeoutId);
|
||||
});
|
||||
|
||||
// start the UI update process; save the timeoutId for canceling
|
||||
timeoutId = $interval(function () {
|
||||
updateTime(); // update DOM
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
angular.module('docsTransclusionDirective', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.name = 'Tobias';
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
templateUrl: 'my-dialog.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsTransclusionExample', [])
|
||||
.controller('Controller', ['$scope', function($scope: any) {
|
||||
$scope.name = 'Tobias';
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {},
|
||||
templateUrl: 'my-dialog.html',
|
||||
link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) {
|
||||
scope['name'] = 'Jeff';
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('docsIsoFnBindExample', [])
|
||||
.controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) {
|
||||
$scope.name = 'Tobias';
|
||||
$scope.hideDialog = function () {
|
||||
$scope.dialogIsHidden = true;
|
||||
$timeout(function () {
|
||||
$scope.dialogIsHidden = false;
|
||||
}, 2000);
|
||||
};
|
||||
}])
|
||||
.directive('myDialog', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {
|
||||
'close': '&onClose'
|
||||
},
|
||||
templateUrl: 'my-dialog-close.html'
|
||||
};
|
||||
});
|
||||
|
||||
angular.module('dragModule', [])
|
||||
.directive('myDraggable', ['$document', function($document: any) {
|
||||
return function(scope: any, element: any, attr: any) {
|
||||
var startX = 0, startY = 0, x = 0, y = 0;
|
||||
|
||||
element.css({
|
||||
position: 'relative',
|
||||
border: '1px solid red',
|
||||
backgroundColor: 'lightgrey',
|
||||
cursor: 'pointer'
|
||||
});
|
||||
|
||||
element.on('mousedown', function(event: any) {
|
||||
// Prevent default dragging of selected content
|
||||
event.preventDefault();
|
||||
startX = event.pageX - x;
|
||||
startY = event.pageY - y;
|
||||
$document.on('mousemove', mousemove);
|
||||
$document.on('mouseup', mouseup);
|
||||
});
|
||||
|
||||
function mousemove(event: any) {
|
||||
y = event.pageY - startY;
|
||||
x = event.pageX - startX;
|
||||
element.css({
|
||||
top: y + 'px',
|
||||
left: x + 'px'
|
||||
});
|
||||
}
|
||||
|
||||
function mouseup() {
|
||||
$document.off('mousemove', mousemove);
|
||||
$document.off('mouseup', mouseup);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
angular.module('docsTabsExample', [])
|
||||
.directive('myTabs', function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {},
|
||||
controller: function($scope: ng.IScope) {
|
||||
var panes: any = $scope['panes'] = [];
|
||||
|
||||
$scope['select'] = function(pane: any) {
|
||||
angular.forEach(panes, function(pane: any) {
|
||||
pane.selected = false;
|
||||
});
|
||||
pane.selected = true;
|
||||
};
|
||||
|
||||
this.addPane = function(pane: any) {
|
||||
if (panes.length === 0) {
|
||||
$scope['select'](pane);
|
||||
}
|
||||
panes.push(pane);
|
||||
};
|
||||
},
|
||||
templateUrl: 'my-tabs.html'
|
||||
};
|
||||
})
|
||||
.directive('myPane', function() {
|
||||
return {
|
||||
require: '^myTabs',
|
||||
restrict: 'E',
|
||||
transclude: true,
|
||||
scope: {
|
||||
title: '@'
|
||||
},
|
||||
link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
|
||||
tabsCtrl.addPane(scope);
|
||||
},
|
||||
templateUrl: 'my-pane.html'
|
||||
};
|
||||
});
|
||||
Vendored
+1189
File diff suppressed because it is too large
Load Diff
Vendored
+1877
File diff suppressed because it is too large
Load Diff
+110
@@ -0,0 +1,110 @@
|
||||
// Type definitions for Angular JS 1.2 (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngAnimate module (angular-animate.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.animate {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AnimateService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/service/$animate
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateService extends ng.IAnimateService {
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(value?: boolean, element?: JQuery): boolean;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
leave(element: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
addClass(element: JQuery, className: string, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @param doneCallback the callback function that will be called once the animation is complete
|
||||
*/
|
||||
removeClass(element: JQuery, className: string, doneCallback?: () => void): void;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @param doneCallback done the callback function (if provided) that will be fired after the CSS classes have been set on the element
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string, doneCallback?: () => void): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularProvider
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/provider/$animateProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: () => ng.IAnimateCallbackObject): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
}
|
||||
+261
@@ -0,0 +1,261 @@
|
||||
// Type definitions for Angular JS 1.3 (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>, Adi Dahiya <https://github.com/adidahiya>, Raphael Schweizer <https://github.com/rasch>, Cody Schaaf <https://github.com/codyschaaf>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
declare module "angular-animate" {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
/**
|
||||
* ngAnimate module (angular-animate.js)
|
||||
*/
|
||||
declare namespace angular.animate {
|
||||
interface IAnimateFactory extends Function {
|
||||
enter?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
|
||||
leave?: (element: ng.IAugmentedJQuery, doneFn: Function) => IAnimateCssRunner|void;
|
||||
addClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
|
||||
removeClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
|
||||
setClass?: (element: ng.IAugmentedJQuery, className: string, doneFn: Function) => IAnimateCssRunner|void;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animate
|
||||
*/
|
||||
interface IAnimateService {
|
||||
/**
|
||||
* Globally enables / disables animations.
|
||||
*
|
||||
* @param element If provided then the element will be used to represent the enable/disable operation.
|
||||
* @param value If provided then set the animation on or off.
|
||||
* @returns current animation state
|
||||
*/
|
||||
enabled(element?: JQuery, value?: boolean): boolean;
|
||||
|
||||
/**
|
||||
* Performs an inline animation on the element.
|
||||
*
|
||||
* @param element the element that will be the focus of the animation
|
||||
* @param from a collection of CSS styles that will be applied to the element at the start of the animation
|
||||
* @param to a collection of CSS styles that the element will animate towards
|
||||
* @param className an optional CSS class that will be added to the element for the duration of the animation (the default class is 'ng-inline-animate')
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
animate(element: JQuery, from: any, to: any, className?: string, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Appends the element to the parentElement element that resides in the document and then runs the enter animation.
|
||||
*
|
||||
* @param element the element that will be the focus of the enter animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the enter animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Runs the leave animation operation and, upon completion, removes the element from the DOM.
|
||||
*
|
||||
* @param element the element that will be the focus of the leave animation
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
leave(element: JQuery, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Fires the move DOM operation. Just before the animation starts, the animate service will either append
|
||||
* it into the parentElement container or add the element directly after the afterElement element if present.
|
||||
* Then the move animation will be run.
|
||||
*
|
||||
* @param element the element that will be the focus of the move animation
|
||||
* @param parentElement the parent element of the element that will be the focus of the move animation
|
||||
* @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then attaches the className
|
||||
* value to the element as a CSS class.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be added to the element and then animated
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
addClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Triggers a custom animation event based off the className variable and then removes the CSS class
|
||||
* provided by the className value from the element.
|
||||
*
|
||||
* @param element the element that will be animated
|
||||
* @param className the CSS class that will be animated and then removed from the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
removeClass(element: JQuery, className: string, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback
|
||||
* will be fired (if provided).
|
||||
*
|
||||
* @param element the element which will have its CSS classes changed removed from it
|
||||
* @param add the CSS classes which will be added to the element
|
||||
* @param remove the CSS class which will be removed from the element CSS classes have been set on the element
|
||||
* @param options an optional collection of styles that will be picked up by the CSS transition/animation
|
||||
* @returns the animation callback promise
|
||||
*/
|
||||
setClass(element: JQuery, add: string, remove: string, options?: IAnimationOptions): IPromise<void>;
|
||||
|
||||
/**
|
||||
* Cancels the provided animation.
|
||||
*/
|
||||
cancel(animationPromise: IPromise<void>): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateProvider
|
||||
* see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider
|
||||
*/
|
||||
interface IAnimateProvider {
|
||||
/**
|
||||
* Registers a new injectable animation factory function.
|
||||
*
|
||||
* @param name The name of the animation.
|
||||
* @param factory The factory function that will be executed to return the animation object.
|
||||
*/
|
||||
register(name: string, factory: () => IAnimateCallbackObject): void;
|
||||
|
||||
/**
|
||||
* Gets and/or sets the CSS class expression that is checked when performing an animation.
|
||||
*
|
||||
* @param expression The className expression which will be checked against all animations.
|
||||
* @returns The current CSS className expression value. If null then there is no expression value.
|
||||
*/
|
||||
classNameFilter(expression?: RegExp): RegExp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Angular Animation Options
|
||||
* see https://docs.angularjs.org/api/ngAnimate/#applying-directive-specific-styles-to-an-animation
|
||||
*/
|
||||
interface IAnimationOptions {
|
||||
/**
|
||||
* The ending CSS styles (a key/value object) that will be applied across the animation via a CSS transition.
|
||||
*/
|
||||
to?: Object;
|
||||
|
||||
/**
|
||||
* The starting CSS styles (a key/value object) that will be applied at the start of the animation.
|
||||
*/
|
||||
from?: Object;
|
||||
|
||||
/**
|
||||
* The DOM event (e.g. enter, leave, move). When used, a generated CSS class of ng-EVENT and
|
||||
* ng-EVENT-active will be applied to the element during the animation. Multiple events can be provided when
|
||||
* spaces are used as a separator. (Note that this will not perform any DOM operation.)
|
||||
*/
|
||||
event?: string;
|
||||
|
||||
/**
|
||||
* The CSS easing value that will be applied to the transition or keyframe animation (or both).
|
||||
*/
|
||||
easing?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS transition style that will be used (e.g. 1s linear all).
|
||||
*/
|
||||
transition?: string;
|
||||
|
||||
/**
|
||||
* The raw CSS keyframe animation style that will be used (e.g. 1s my_animation linear).
|
||||
*/
|
||||
keyframe?: string;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be added to the element and spread across the animation.
|
||||
*/
|
||||
addClass?: string;
|
||||
|
||||
/**
|
||||
* A space separated list of CSS classes that will be removed from the element and spread across
|
||||
* the animation.
|
||||
*/
|
||||
removeClass?: string;
|
||||
|
||||
/**
|
||||
* A number value representing the total duration of the transition and/or keyframe (note that a value
|
||||
* of 1 is 1000ms). If a value of 0 is provided then the animation will be skipped entirely.
|
||||
*/
|
||||
duration?: number;
|
||||
|
||||
/**
|
||||
* A number value representing the total delay of the transition and/or keyframe (note that a value of
|
||||
* 1 is 1000ms). If a value of true is used then whatever delay value is detected from the CSS classes will be
|
||||
* mirrored on the elements styles (e.g. by setting delay true then the style value of the element will be
|
||||
* transition-delay: DETECTED_VALUE). Using true is useful when you want the CSS classes and inline styles to
|
||||
* all share the same CSS delay value.
|
||||
*/
|
||||
delay?: number;
|
||||
|
||||
/**
|
||||
* A numeric time value representing the delay between successively animated elements (Click here to
|
||||
* learn how CSS-based staggering works in ngAnimate.)
|
||||
*/
|
||||
stagger?: number;
|
||||
|
||||
/**
|
||||
* The numeric index representing the stagger item (e.g. a value of 5 is equal to the sixth item
|
||||
* in the stagger; therefore when a stagger option value of 0.1 is used then there will be a stagger delay of 600ms)
|
||||
* applyClassesEarly - Whether or not the classes being added or removed will be used when detecting the animation.
|
||||
* This is set by $animate when enter/leave/move animations are fired to ensure that the CSS classes are resolved in time.
|
||||
* (Note that this will prevent any transitions from occuring on the classes being added and removed.)
|
||||
*/
|
||||
staggerIndex?: number;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunner {
|
||||
/**
|
||||
* Starts the animation
|
||||
*
|
||||
* @returns The animation runner with a done function for supplying a callback.
|
||||
*/
|
||||
start(): IAnimateCssRunnerStart;
|
||||
|
||||
/**
|
||||
* Ends (aborts) the animation
|
||||
*/
|
||||
end(): void;
|
||||
}
|
||||
|
||||
interface IAnimateCssRunnerStart extends IPromise<void> {
|
||||
/**
|
||||
* Allows you to add done callbacks to the running animation
|
||||
*
|
||||
* @param callbackFn: the callback function to be run
|
||||
*/
|
||||
done(callbackFn: (animationFinished: boolean) => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* AnimateCssService
|
||||
* see http://docs.angularjs.org/api/ngAnimate/service/$animateCss
|
||||
*/
|
||||
interface IAnimateCssService {
|
||||
(element: JQuery, animateCssOptions: IAnimationOptions): IAnimateCssRunner;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
declare namespace angular {
|
||||
interface IModule {
|
||||
animate(cssSelector: string, animateFactory: angular.animate.IAnimateFactory): IModule;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// Type definitions for Angular JS 1.0 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngCookies module (angular-cookies.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.cookies {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieService
|
||||
// see http://docs.angularjs.org/api/ngCookies.$cookies
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookiesService {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieStoreService
|
||||
// see http://docs.angularjs.org/api/ngCookies.$cookieStore
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookieStoreService {
|
||||
get(key: string): any;
|
||||
put(key: string, value: any): void;
|
||||
remove(key: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Type definitions for Angular JS 1.2 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngCookies module (angular-cookies.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.cookies {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookies
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookiesService {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CookieStoreService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ICookieStoreService {
|
||||
/**
|
||||
* Returns the value of given cookie key
|
||||
* @param key Id to use for lookup
|
||||
*/
|
||||
get(key: string): any;
|
||||
/**
|
||||
* Sets a value for given cookie key
|
||||
* @param key Id for the value
|
||||
* @param value Value to be stored
|
||||
*/
|
||||
put(key: string, value: any): void;
|
||||
/**
|
||||
* Remove given cookie
|
||||
* @param key Id of the key-value pair to delete
|
||||
*/
|
||||
remove(key: string): void;
|
||||
}
|
||||
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare var module: (...modules: any[]) => any;
|
||||
declare var inject: (...fns: Function[]) => any;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngMock module (angular-mocks.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// We reopen it to add the MockStatic definition
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAngularStatic {
|
||||
mock: IMockStatic;
|
||||
}
|
||||
|
||||
interface IMockStatic {
|
||||
// see http://docs.angularjs.org/api/angular.mock.debug
|
||||
debug(obj: any): string;
|
||||
|
||||
// see http://docs.angularjs.org/api/angular.mock.inject
|
||||
inject(...fns: Function[]): any;
|
||||
|
||||
// see http://docs.angularjs.org/api/angular.mock.module
|
||||
module(...modules: any[]): any;
|
||||
|
||||
// see http://docs.angularjs.org/api/angular.mock.TzDate
|
||||
TzDate(offset: number, timestamp: number): Date;
|
||||
TzDate(offset: number, timestamp: string): Date;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
// see http://docs.angularjs.org/api/ngMock.$exceptionHandler
|
||||
// see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IExceptionHandlerProvider extends IServiceProvider {
|
||||
mode(mode: string): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
// see http://docs.angularjs.org/api/ngMock.$timeout
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
flush(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
// see http://docs.angularjs.org/api/ngMock.$log
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILogService {
|
||||
assertEmpty(): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface LogCall {
|
||||
logs: string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see http://docs.angularjs.org/api/ngMock.$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
flush(count?: number): void;
|
||||
resetExpectations(): void;
|
||||
verifyNoOutstandingExpectation(): void;
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
|
||||
|
||||
when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler;
|
||||
when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
|
||||
when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
|
||||
expectDELETE(url: string, headers?: any): mock.IRequestHandler;
|
||||
expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
expectGET(url: string, headers?: any): mock.IRequestHandler;
|
||||
expectGET(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
expectHEAD(url: string, headers?: any): mock.IRequestHandler;
|
||||
expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
expectJSONP(url: string): mock.IRequestHandler;
|
||||
expectJSONP(url: RegExp): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler;
|
||||
|
||||
whenDELETE(url: string, headers?: any): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenGET(url: string, headers?: any): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenHEAD(url: string, headers?: any): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenJSONP(url: string): mock.IRequestHandler;
|
||||
whenJSONP(url: RegExp): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
export module mock {
|
||||
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
respond(func: Function): void;
|
||||
respond(status: number, data?: any, headers?: any): void;
|
||||
respond(data: any, headers?: any): void;
|
||||
|
||||
// Available wehn ngMockE2E is loaded
|
||||
passThrough(): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,305 @@
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IAngularStatic
|
||||
///////////////////////////////////////
|
||||
var angular: ng.IAngularStatic;
|
||||
var mock: ng.IMockStatic;
|
||||
|
||||
mock = angular.mock;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IMockStatic
|
||||
///////////////////////////////////////
|
||||
var date: Date;
|
||||
|
||||
mock.dump({ key: 'value' });
|
||||
|
||||
mock.inject(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]);
|
||||
|
||||
// This overload is not documented on the website, but flows from
|
||||
// how the injector works.
|
||||
mock.inject(
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }],
|
||||
['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]);
|
||||
|
||||
mock.module('module1', 'module2');
|
||||
mock.module(
|
||||
function () { return 1; },
|
||||
function () { return 2; }
|
||||
);
|
||||
mock.module({ module1: function () { return 1; } });
|
||||
|
||||
date = mock.TzDate(-7, '2013-1-1T15:00:00Z');
|
||||
date = mock.TzDate(-8, 12345678);
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IExceptionHandlerProvider
|
||||
///////////////////////////////////////
|
||||
var exceptionHandlerProvider: ng.IExceptionHandlerProvider;
|
||||
|
||||
exceptionHandlerProvider.mode('log');
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// ITimeoutService
|
||||
///////////////////////////////////////
|
||||
var timeoutService: ng.ITimeoutService;
|
||||
|
||||
timeoutService.flush();
|
||||
timeoutService.flush(1234);
|
||||
timeoutService.flushNext();
|
||||
timeoutService.flushNext(1234);
|
||||
timeoutService.verifyNoPendingTasks();
|
||||
|
||||
////////////////////////////////////////
|
||||
// IIntervalService
|
||||
////////////////////////////////////////
|
||||
var intervalService: ng.IIntervalService;
|
||||
var intervalServiceTimeActuallyAdvanced: number;
|
||||
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush();
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush(1234);
|
||||
|
||||
///////////////////////////////////////
|
||||
// ILogService, ILogCall
|
||||
///////////////////////////////////////
|
||||
var logService: ng.ILogService;
|
||||
var logCall: ng.ILogCall;
|
||||
var logs: string[];
|
||||
|
||||
logService.assertEmpty();
|
||||
logService.reset();
|
||||
|
||||
logCall = logService.debug;
|
||||
logCall = logService.error;
|
||||
logCall = logService.info;
|
||||
logCall = logService.log;
|
||||
logCall = logService.warn;
|
||||
|
||||
logs = logCall.logs;
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IHttpBackendService
|
||||
///////////////////////////////////////
|
||||
var httpBackendService: ng.IHttpBackendService;
|
||||
var requestHandler: ng.mock.IRequestHandler;
|
||||
|
||||
httpBackendService.flush();
|
||||
httpBackendService.flush(1234);
|
||||
httpBackendService.resetExpectations();
|
||||
httpBackendService.verifyNoOutstandingExpectation();
|
||||
httpBackendService.verifyNoOutstandingRequest();
|
||||
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET('http://test.local');
|
||||
requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.expectJSONP(/test.local/);
|
||||
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data');
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/);
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; });
|
||||
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local');
|
||||
requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET('http://test.local');
|
||||
requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local');
|
||||
requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenJSONP('http://test.local');
|
||||
requestHandler = httpBackendService.whenJSONP(/test.local/);
|
||||
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data');
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/);
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data');
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/);
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' });
|
||||
requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' });
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IRequestHandler
|
||||
///////////////////////////////////////
|
||||
requestHandler.passThrough();
|
||||
requestHandler.respond(function () { });
|
||||
requestHandler.respond({ key: 'value' });
|
||||
requestHandler.respond({ key: 'value' }, { header: 'value' });
|
||||
requestHandler.respond(404);
|
||||
requestHandler.respond(404, { key: 'value' });
|
||||
requestHandler.respond(404, { key: 'value' }, { header: 'value' });
|
||||
+226
@@ -0,0 +1,226 @@
|
||||
// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// functions attached to global object (window)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare var module: (...modules: any[]) => any;
|
||||
declare var inject: (...fns: Function[]) => any;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngMock module (angular-mocks.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// AngularStatic
|
||||
// We reopen it to add the MockStatic definition
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IAngularStatic {
|
||||
mock: IMockStatic;
|
||||
}
|
||||
|
||||
interface IMockStatic {
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.dump
|
||||
dump(obj: any): string;
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.inject
|
||||
inject(...fns: Function[]): any;
|
||||
inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.module
|
||||
module(...modules: any[]): any;
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/type/angular.mock.TzDate
|
||||
TzDate(offset: number, timestamp: number): Date;
|
||||
TzDate(offset: number, timestamp: string): Date;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ExceptionHandlerService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$exceptionHandler
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/provider/$exceptionHandlerProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IExceptionHandlerProvider extends IServiceProvider {
|
||||
mode(mode: string): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$timeout
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ITimeoutService {
|
||||
flush(delay?: number): void;
|
||||
flushNext(expectedDelay?: number): void;
|
||||
verifyNoPendingTasks(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IntervalService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$interval
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IIntervalService {
|
||||
flush(millis?: number): number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$log
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ILogService {
|
||||
assertEmpty(): void;
|
||||
reset(): void;
|
||||
}
|
||||
|
||||
interface ILogCall {
|
||||
logs: string[];
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// HttpBackendService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$httpBackend
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IHttpBackendService {
|
||||
flush(count?: number): void;
|
||||
resetExpectations(): void;
|
||||
verifyNoOutstandingExpectation(): void;
|
||||
verifyNoOutstandingRequest(): void;
|
||||
|
||||
expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
expectDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectJSONP(url: string): mock.IRequestHandler;
|
||||
expectJSONP(url: RegExp): mock.IRequestHandler;
|
||||
|
||||
expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenDELETE(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenGET(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenHEAD(url: string, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler;
|
||||
|
||||
whenJSONP(url: string): mock.IRequestHandler;
|
||||
whenJSONP(url: RegExp): mock.IRequestHandler;
|
||||
|
||||
whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
|
||||
whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler;
|
||||
whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler;
|
||||
}
|
||||
|
||||
export module mock {
|
||||
|
||||
// returned interface by the the mocked HttpBackendService expect/when methods
|
||||
interface IRequestHandler {
|
||||
respond(func: Function): void;
|
||||
respond(status: number, data?: any, headers?: any): void;
|
||||
respond(data: any, headers?: any): void;
|
||||
|
||||
// Available wehn ngMockE2E is loaded
|
||||
passThrough(): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
// Type definitions for Angular JS 1.0 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngResource module (angular-resource.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.resource {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see http://docs.angularjs.org/api/ngResource.$resource
|
||||
// Most part of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
method: string;
|
||||
isArray?: boolean;
|
||||
params?: any;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
interface IResourceClass {
|
||||
get: IActionCall;
|
||||
save: IActionCall;
|
||||
query: IActionCall;
|
||||
remove: IActionCall;
|
||||
delete: IActionCall;
|
||||
}
|
||||
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
interface IActionCall {
|
||||
(): IResource;
|
||||
(dataOrParams: any): IResource;
|
||||
(dataOrParams: any, success: Function): IResource;
|
||||
(success: Function, error?: Function): IResource;
|
||||
(params: any, data: any, success?: Function, error?: Function): IResource;
|
||||
}
|
||||
|
||||
interface IResource {
|
||||
$save: IActionCall;
|
||||
$remove: IActionCall;
|
||||
$delete: IActionCall;
|
||||
|
||||
// No documented, but they are there, just as any custom action will be
|
||||
$query: IActionCall;
|
||||
$get: IActionCall;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction {
|
||||
($resource: ng.resource.IResourceService): ng.resource.IResourceClass;
|
||||
}
|
||||
}
|
||||
|
||||
/** extensions to base ng based on using angular-resource */
|
||||
declare namespace ng {
|
||||
|
||||
interface IModule {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
|
||||
|
||||
interface IMyResource extends ng.resource.IResource<IMyResource> { };
|
||||
interface IMyResourceClass extends ng.resource.IResourceClass<IMyResource> { };
|
||||
|
||||
///////////////////////////////////////
|
||||
// IActionDescriptor
|
||||
///////////////////////////////////////
|
||||
var actionDescriptor: ng.resource.IActionDescriptor;
|
||||
|
||||
actionDescriptor.headers = { header: 'value' };
|
||||
actionDescriptor.isArray = true;
|
||||
actionDescriptor.method = 'method action';
|
||||
actionDescriptor.params = { key: 'value' };
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceClass
|
||||
///////////////////////////////////////
|
||||
var resourceClass: IMyResourceClass;
|
||||
var resource: IMyResource;
|
||||
var resourceArray: ng.resource.IResourceArray<IMyResource>;
|
||||
|
||||
resource = resourceClass.delete();
|
||||
resource = resourceClass.delete({ key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, function () { });
|
||||
resource = resourceClass.delete(function () { });
|
||||
resource = resourceClass.delete(function () { }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resource.$promise.then(function(data: IMyResource) {});
|
||||
|
||||
resource = resourceClass.get();
|
||||
resource = resourceClass.get({ key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, function () { });
|
||||
resource = resourceClass.get(function () { });
|
||||
resource = resourceClass.get(function () { }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resourceArray = resourceClass.query();
|
||||
resourceArray = resourceClass.query({ key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query(function () { });
|
||||
resourceArray = resourceClass.query(function () { }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
resourceArray.push(resource);
|
||||
resourceArray.$promise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
resource = resourceClass.remove();
|
||||
resource = resourceClass.remove({ key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, function () { });
|
||||
resource = resourceClass.remove(function () { });
|
||||
resource = resourceClass.remove(function () { }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
resource = resourceClass.save();
|
||||
resource = resourceClass.save({ key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, function () { });
|
||||
resource = resourceClass.save(function () { });
|
||||
resource = resourceClass.save(function () { }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { });
|
||||
resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
|
||||
var promise : ng.IPromise<IMyResource>;
|
||||
var arrayPromise : ng.IPromise<IMyResource[]>;
|
||||
|
||||
promise = resource.$delete();
|
||||
promise = resource.$delete({ key: 'value' });
|
||||
promise = resource.$delete({ key: 'value' }, function () { });
|
||||
promise = resource.$delete(function () { });
|
||||
promise = resource.$delete(function () { }, function () { });
|
||||
promise = resource.$delete({ key: 'value' }, function () { }, function () { });
|
||||
promise.then(function(data: IMyResource) {});
|
||||
|
||||
promise = resource.$get();
|
||||
promise = resource.$get({ key: 'value' });
|
||||
promise = resource.$get({ key: 'value' }, function () { });
|
||||
promise = resource.$get(function () { });
|
||||
promise = resource.$get(function () { }, function () { });
|
||||
promise = resource.$get({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
arrayPromise = resourceArray[0].$query();
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { });
|
||||
arrayPromise = resourceArray[0].$query(function () { }, function () { });
|
||||
arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { });
|
||||
arrayPromise.then(function(data: ng.resource.IResourceArray<IMyResource>) {});
|
||||
|
||||
promise = resource.$remove();
|
||||
promise = resource.$remove({ key: 'value' });
|
||||
promise = resource.$remove({ key: 'value' }, function () { });
|
||||
promise = resource.$remove(function () { });
|
||||
promise = resource.$remove(function () { }, function () { });
|
||||
promise = resource.$remove({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
promise = resource.$save();
|
||||
promise = resource.$save({ key: 'value' });
|
||||
promise = resource.$save({ key: 'value' }, function () { });
|
||||
promise = resource.$save(function () { });
|
||||
promise = resource.$save(function () { }, function () { });
|
||||
promise = resource.$save({ key: 'value' }, function () { }, function () { });
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResourceService
|
||||
///////////////////////////////////////
|
||||
var resourceService: ng.resource.IResourceService;
|
||||
resourceClass = resourceService<IMyResource, IMyResourceClass>('test');
|
||||
resourceClass = resourceService<IMyResource>('test');
|
||||
resourceClass = resourceService('test');
|
||||
|
||||
///////////////////////////////////////
|
||||
// IModule
|
||||
///////////////////////////////////////
|
||||
var mod: ng.IModule;
|
||||
var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<IMyResource>;
|
||||
var resourceService: ng.resource.IResourceService;
|
||||
|
||||
resourceClass = resourceServiceFactoryFunction<IMyResourceClass>(resourceService);
|
||||
|
||||
resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return <any>resourceClass; };
|
||||
mod = mod.factory('factory name', resourceServiceFactoryFunction);
|
||||
|
||||
///////////////////////////////////////
|
||||
// IResource
|
||||
///////////////////////////////////////
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
// Type definitions for Angular JS 1.2 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngResource module (angular-resource.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.resource {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngResource/service/$resource
|
||||
// Most of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actionDescriptors?: any): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
method: string;
|
||||
isArray?: boolean;
|
||||
params?: any;
|
||||
headers?: any;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
//
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
|
||||
//
|
||||
// Only those methods with an HTTP body do have 'data' as first parameter:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
|
||||
// More specifically, those methods are POST, PUT and PATCH:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
|
||||
//
|
||||
// Also, static calls always return the IResource (or IResourceArray) retrieved
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
|
||||
interface IResourceClass<T> {
|
||||
new(dataOrParams? : any) : T;
|
||||
get(): T;
|
||||
get(params: Object): T;
|
||||
get(success: Function, error?: Function): T;
|
||||
get(params: Object, success: Function, error?: Function): T;
|
||||
get(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
query(): IResourceArray<T>;
|
||||
query(params: Object): IResourceArray<T>;
|
||||
query(success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
|
||||
|
||||
save(): T;
|
||||
save(data: Object): T;
|
||||
save(success: Function, error?: Function): T;
|
||||
save(data: Object, success: Function, error?: Function): T;
|
||||
save(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
remove(): T;
|
||||
remove(params: Object): T;
|
||||
remove(success: Function, error?: Function): T;
|
||||
remove(params: Object, success: Function, error?: Function): T;
|
||||
remove(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
delete(): T;
|
||||
delete(params: Object): T;
|
||||
delete(success: Function, error?: Function): T;
|
||||
delete(params: Object, success: Function, error?: Function): T;
|
||||
delete(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
}
|
||||
|
||||
// Instance calls always return the the promise of the request which retrieved the object
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
|
||||
interface IResource<T> {
|
||||
$get(): ng.IPromise<T>;
|
||||
$get(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$get(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$query(): ng.IPromise<IResourceArray<T>>;
|
||||
$query(params?: Object, success?: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
|
||||
$query(success: Function, error?: Function): ng.IPromise<IResourceArray<T>>;
|
||||
|
||||
$save(): ng.IPromise<T>;
|
||||
$save(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$save(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$remove(): ng.IPromise<T>;
|
||||
$remove(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$remove(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
$delete(): ng.IPromise<T>;
|
||||
$delete(params?: Object, success?: Function, error?: Function): ng.IPromise<T>;
|
||||
$delete(success: Function, error?: Function): ng.IPromise<T>;
|
||||
|
||||
/** the promise of the original server interaction that created this instance. **/
|
||||
$promise : ng.IPromise<T>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Really just a regular Array object with $promise and $resolve attached to it
|
||||
*/
|
||||
interface IResourceArray<T> extends Array<T> {
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : ng.IPromise<IResourceArray<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction<T> {
|
||||
($resource: ng.resource.IResourceService): IResourceClass<T>;
|
||||
<U extends IResourceClass<T>>($resource: ng.resource.IResourceService): U;
|
||||
}
|
||||
}
|
||||
|
||||
/** extensions to base ng based on using angular-resource */
|
||||
declare namespace ng {
|
||||
|
||||
interface IModule {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction<any>): IModule;
|
||||
}
|
||||
}
|
||||
|
||||
interface Array<T>
|
||||
{
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : ng.IPromise<Array<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
// Type definitions for Angular JS 1.3 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
declare module 'angular-resource' {
|
||||
var _: string;
|
||||
export = _;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngResource module (angular-resource.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace angular.resource {
|
||||
|
||||
/**
|
||||
* Currently supported options for the $resource factory options argument.
|
||||
*/
|
||||
interface IResourceOptions {
|
||||
/**
|
||||
* If true then the trailing slashes from any calculated URL will be stripped (defaults to true)
|
||||
*/
|
||||
stripTrailingSlashes?: boolean;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ResourceService
|
||||
// see http://docs.angularjs.org/api/ngResource.$resource
|
||||
// Most part of the following definitions were achieved by analyzing the
|
||||
// actual implementation, since the documentation doesn't seem to cover
|
||||
// that deeply.
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IResourceService {
|
||||
(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<IResource<any>>;
|
||||
<T, U>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): U;
|
||||
<T>(url: string, paramDefaults?: any,
|
||||
/** example: {update: { method: 'PUT' }, delete: deleteDescriptor }
|
||||
where deleteDescriptor : IActionDescriptor */
|
||||
actions?: any, options?: IResourceOptions): IResourceClass<T>;
|
||||
}
|
||||
|
||||
// Just a reference to facilitate describing new actions
|
||||
interface IActionDescriptor {
|
||||
method: string;
|
||||
params?: any;
|
||||
url?: string;
|
||||
isArray?: boolean;
|
||||
transformRequest?: angular.IHttpRequestTransformer | angular.IHttpRequestTransformer[];
|
||||
transformResponse?: angular.IHttpResponseTransformer | angular.IHttpResponseTransformer[];
|
||||
headers?: any;
|
||||
cache?: boolean | angular.ICacheObject;
|
||||
timeout?: number | angular.IPromise<any>;
|
||||
withCredentials?: boolean;
|
||||
responseType?: string;
|
||||
interceptor?: any;
|
||||
}
|
||||
|
||||
// Baseclass for everyresource with default actions.
|
||||
// If you define your new actions for the resource, you will need
|
||||
// to extend this interface and typecast the ResourceClass to it.
|
||||
//
|
||||
// In case of passing the first argument as anything but a function,
|
||||
// it's gonna be considered data if the action method is POST, PUT or
|
||||
// PATCH (in other words, methods with body). Otherwise, it's going
|
||||
// to be considered as parameters to the request.
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465
|
||||
//
|
||||
// Only those methods with an HTTP body do have 'data' as first parameter:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463
|
||||
// More specifically, those methods are POST, PUT and PATCH:
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432
|
||||
//
|
||||
// Also, static calls always return the IResource (or IResourceArray) retrieved
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549
|
||||
interface IResourceClass<T> {
|
||||
new(dataOrParams? : any) : T;
|
||||
get(): T;
|
||||
get(params: Object): T;
|
||||
get(success: Function, error?: Function): T;
|
||||
get(params: Object, success: Function, error?: Function): T;
|
||||
get(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
query(): IResourceArray<T>;
|
||||
query(params: Object): IResourceArray<T>;
|
||||
query(success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, success: Function, error?: Function): IResourceArray<T>;
|
||||
query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray<T>;
|
||||
|
||||
save(): T;
|
||||
save(data: Object): T;
|
||||
save(success: Function, error?: Function): T;
|
||||
save(data: Object, success: Function, error?: Function): T;
|
||||
save(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
remove(): T;
|
||||
remove(params: Object): T;
|
||||
remove(success: Function, error?: Function): T;
|
||||
remove(params: Object, success: Function, error?: Function): T;
|
||||
remove(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
|
||||
delete(): T;
|
||||
delete(params: Object): T;
|
||||
delete(success: Function, error?: Function): T;
|
||||
delete(params: Object, success: Function, error?: Function): T;
|
||||
delete(params: Object, data: Object, success?: Function, error?: Function): T;
|
||||
}
|
||||
|
||||
// Instance calls always return the the promise of the request which retrieved the object
|
||||
// https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546
|
||||
interface IResource<T> {
|
||||
$get(): angular.IPromise<T>;
|
||||
$get(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$get(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$query(): angular.IPromise<IResourceArray<T>>;
|
||||
$query(params?: Object, success?: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
$query(success: Function, error?: Function): angular.IPromise<IResourceArray<T>>;
|
||||
|
||||
$save(): angular.IPromise<T>;
|
||||
$save(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$save(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$remove(): angular.IPromise<T>;
|
||||
$remove(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$remove(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
$delete(): angular.IPromise<T>;
|
||||
$delete(params?: Object, success?: Function, error?: Function): angular.IPromise<T>;
|
||||
$delete(success: Function, error?: Function): angular.IPromise<T>;
|
||||
|
||||
/** the promise of the original server interaction that created this instance. **/
|
||||
$promise : angular.IPromise<T>;
|
||||
$resolved : boolean;
|
||||
toJSON: () => {
|
||||
[index: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Really just a regular Array object with $promise and $resolve attached to it
|
||||
*/
|
||||
interface IResourceArray<T> extends Array<T & IResource<T>> {
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : angular.IPromise<IResourceArray<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
|
||||
/** when creating a resource factory via IModule.factory */
|
||||
interface IResourceServiceFactoryFunction<T> {
|
||||
($resource: angular.resource.IResourceService): IResourceClass<T>;
|
||||
<U extends IResourceClass<T>>($resource: angular.resource.IResourceService): U;
|
||||
}
|
||||
|
||||
// IResourceServiceProvider used to configure global settings
|
||||
interface IResourceServiceProvider extends angular.IServiceProvider {
|
||||
|
||||
defaults: IResourceOptions;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** extensions to base ng based on using angular-resource */
|
||||
declare namespace angular {
|
||||
|
||||
interface IModule {
|
||||
/** creating a resource service factory */
|
||||
factory(name: string, resourceServiceFactoryFunction: angular.resource.IResourceServiceFactoryFunction<any>): IModule;
|
||||
}
|
||||
}
|
||||
|
||||
interface Array<T>
|
||||
{
|
||||
/** the promise of the original server interaction that created this collection. **/
|
||||
$promise : angular.IPromise<Array<T>>;
|
||||
$resolved : boolean;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
/**
|
||||
* @license HTTP Auth Interceptor Module for AngularJS
|
||||
* (c) 2013 Jonathan Park @ Daptiv Solutions Inc
|
||||
* License: MIT
|
||||
*/
|
||||
|
||||
declare var $routeProvider: ng.route.IRouteProvider;
|
||||
$routeProvider
|
||||
.when('/projects/:projectId/dashboard',{
|
||||
controller: '',
|
||||
templateUrl: '',
|
||||
caseInsensitiveMatch: true,
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.otherwise({redirectTo: '/'});
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
// Type definitions for Angular JS 1.2 (ngRoute module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Jonathan Park <https://github.com/park9140>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngRoute module (angular-route.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.route {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteParamsService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$routeParams
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteParamsService {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteService {
|
||||
/**
|
||||
* Causes $route service to reload the current route even if $location hasn't changed.
|
||||
* As a result of that, ngView creates new scope, reinstantiates the controller.
|
||||
*/
|
||||
reload(): void;
|
||||
|
||||
/**
|
||||
* Object with all route configuration Objects as its properties.
|
||||
*/
|
||||
routes: any;
|
||||
|
||||
// May not always be available. For instance, current will not be available
|
||||
// to a controller that was not initialized as a result of a route maching.
|
||||
current?: ICurrentRoute;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider#when for API documentation
|
||||
*/
|
||||
interface IRoute {
|
||||
/**
|
||||
* {(string|function()=}
|
||||
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
|
||||
*/
|
||||
controller?: any;
|
||||
/**
|
||||
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
|
||||
*/
|
||||
controllerAs?: string;
|
||||
/**
|
||||
* Undocumented?
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
|
||||
*
|
||||
* If template is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
template?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Path or function that returns a path to an html template that should be used by ngView.
|
||||
*
|
||||
* If templateUrl is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
templateUrl?: any;
|
||||
/**
|
||||
* {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
|
||||
*
|
||||
* - key - {string}: a name of a dependency to be injected into the controller.
|
||||
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
|
||||
*/
|
||||
resolve?: {[key: string]: any};
|
||||
/**
|
||||
* {(string|function())=}
|
||||
* Value to update $location path with and trigger route redirection.
|
||||
*
|
||||
* If redirectTo is a function, it will be called with the following parameters:
|
||||
*
|
||||
* - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
|
||||
* - {string} - current $location.path()
|
||||
* - {Object} - current $location.search()
|
||||
* - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
|
||||
*/
|
||||
redirectTo?: any;
|
||||
/**
|
||||
* Reload route when only $location.search() or $location.hash() changes.
|
||||
*
|
||||
* This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
|
||||
*/
|
||||
reloadOnSearch?: boolean;
|
||||
/**
|
||||
* Match routes without being case sensitive
|
||||
*
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
}
|
||||
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route#current
|
||||
interface ICurrentRoute extends IRoute {
|
||||
locals: {
|
||||
$scope: IScope;
|
||||
$template: string;
|
||||
};
|
||||
|
||||
params: any;
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
/**
|
||||
* Sets route definition that will be used on route change when no other route definition is matched.
|
||||
*
|
||||
* @params Mapping information to be assigned to $route.current.
|
||||
*/
|
||||
otherwise(params: IRoute): IRouteProvider;
|
||||
/**
|
||||
* Adds a new route definition to the $route service.
|
||||
*
|
||||
* @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
|
||||
*
|
||||
* - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain optional named groups with a question mark: e.g.:name?.
|
||||
*
|
||||
* For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
|
||||
*
|
||||
* @param route Mapping information to be assigned to $route.current on route match.
|
||||
*/
|
||||
when(path: string, route: IRoute): IRouteProvider;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for Angular JS 1.0 (ngSanitize module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngSanitize module (angular-sanitize.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.sanitize {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SanitizeService
|
||||
// see http://docs.angularjs.org/api/ngSanitize.$sanitize
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ISanitizeService {
|
||||
(html: string): string;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
var shouldBeString: string;
|
||||
|
||||
declare var $sanitizeService: ng.sanitize.ISanitizeService;
|
||||
shouldBeString = $sanitizeService(shouldBeString);
|
||||
|
||||
declare var $linky: ng.sanitize.filter.ILinky;
|
||||
shouldBeString = $linky(shouldBeString);
|
||||
shouldBeString = $linky(shouldBeString, shouldBeString);
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for Angular JS 1.2 (ngSanitize module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// ngSanitize module (angular-sanitize.js)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
declare namespace ng.sanitize {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SanitizeService
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/service/$sanitize
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface ISanitizeService {
|
||||
(html: string): string;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Filters included with the ngSanitize
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
export module filter {
|
||||
|
||||
// Finds links in text input and turns them into html links.
|
||||
// Supports http/https/ftp/mailto and plain email address links.
|
||||
// see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter/linky
|
||||
interface ILinky {
|
||||
(text: string, target?: string): string;
|
||||
}
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
// Type definitions for Angular Scenario Testing 1.0 (ngScenario module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace angularScenario {
|
||||
export interface AngularModel {
|
||||
scenario: any;
|
||||
}
|
||||
|
||||
export interface RunFunction {
|
||||
(functionToRun: any): any;
|
||||
}
|
||||
export interface RunFunctionWithDescription {
|
||||
(description: string, functionToRun: any): any;
|
||||
}
|
||||
|
||||
export interface PauseFunction {
|
||||
(): any;
|
||||
}
|
||||
|
||||
export interface SleepFunction {
|
||||
(seconds: number): any;
|
||||
}
|
||||
|
||||
export interface Future {
|
||||
}
|
||||
|
||||
export interface testWindow {
|
||||
href(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface testLocation {
|
||||
url(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface Browser {
|
||||
navigateTo(url: string): void;
|
||||
navigateTo(urlDescription: string, urlFunction: () => string): void;
|
||||
reload(): void;
|
||||
window(): testWindow;
|
||||
location(): testLocation;
|
||||
}
|
||||
|
||||
export interface Matchers {
|
||||
toEqual(value: any): void;
|
||||
toBe(value: any): void;
|
||||
toBeDefined(): void;
|
||||
toBeTruthy(): void;
|
||||
toBeFalsy(): void;
|
||||
toMatch(regularExpression: any): void;
|
||||
toBeNull(): void;
|
||||
toContain(value: any): void;
|
||||
toBeLessThan(value: any): void;
|
||||
toBeGreaterThan(value: any): void;
|
||||
}
|
||||
|
||||
export interface CustomMatchers extends Matchers{
|
||||
}
|
||||
|
||||
export interface Expect extends CustomMatchers {
|
||||
not(): angularScenario.CustomMatchers;
|
||||
}
|
||||
|
||||
export interface UsingFunction {
|
||||
(selector: string, selectorDescription?: string): void;
|
||||
}
|
||||
|
||||
export interface BindingFunction {
|
||||
(bracketBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Input {
|
||||
enter(value: any);
|
||||
check(): any;
|
||||
select(radioButtonValue: any): any;
|
||||
val(): Future;
|
||||
}
|
||||
|
||||
export interface Repeater {
|
||||
count(): Future;
|
||||
row(index: number): Future;
|
||||
column(ngBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Select {
|
||||
option(value: any): any;
|
||||
option(...listOfValues: any[]): any;
|
||||
}
|
||||
|
||||
export interface Element {
|
||||
count(): Future;
|
||||
click(): any;
|
||||
query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) =>any): any;
|
||||
val(): Future;
|
||||
text(): Future;
|
||||
html(): Future;
|
||||
height(): Future;
|
||||
innerHeight(): Future;
|
||||
outerHeight(): Future;
|
||||
width(): Future;
|
||||
innerWidth(): Future;
|
||||
outerWidth(): Future;
|
||||
position(): Future;
|
||||
scrollLeft(): Future;
|
||||
scrollTop(): Future;
|
||||
offset(): Future;
|
||||
|
||||
val(value: any): void;
|
||||
text(value: any): void;
|
||||
html(value: any): void;
|
||||
height(value: any): void;
|
||||
innerHeight(value: any): void;
|
||||
outerHeight(value: any): void;
|
||||
width(value: any): void;
|
||||
innerWidth(value: any): void;
|
||||
outerWidth(value: any): void;
|
||||
position(value: any): void;
|
||||
scrollLeft(value: any): void;
|
||||
scrollTop(value: any): void;
|
||||
offset(value: any): void;
|
||||
|
||||
attr(key: any): Future;
|
||||
prop(key: any): Future;
|
||||
css(key: any): Future;
|
||||
|
||||
attr(key: any, value: any): void;
|
||||
prop(key: any, value: any): void;
|
||||
css(key: any, value: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var describe: angularScenario.RunFunctionWithDescription;
|
||||
declare var xdescribe: angularScenario.RunFunctionWithDescription;
|
||||
declare var beforeEach: angularScenario.RunFunction;
|
||||
declare var afterEach: angularScenario.RunFunction;
|
||||
declare var it: angularScenario.RunFunctionWithDescription;
|
||||
declare var xit: angularScenario.RunFunctionWithDescription;
|
||||
declare var pause: angularScenario.PauseFunction;
|
||||
declare var sleep: angularScenario.SleepFunction;
|
||||
declare function browser(): angularScenario.Browser;
|
||||
declare function expect(expectation: angularScenario.Future): angularScenario.Expect;
|
||||
declare var using: angularScenario.UsingFunction;
|
||||
declare var binding: angularScenario.BindingFunction;
|
||||
declare function input(ngModelBinding: string): angularScenario.Input;
|
||||
declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater;
|
||||
declare function select(ngModelBinding: string): angularScenario.Select;
|
||||
declare function element(selector: string, elementDescription?: string): angularScenario.Element;
|
||||
declare var angular: angularScenario.AngularModel;
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
// Type definitions for Angular Scenario Testing 1.2 (ngScenario module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="jquery" />
|
||||
|
||||
declare namespace ng {
|
||||
export interface IAngularStatic {
|
||||
scenario: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace angularScenario {
|
||||
|
||||
export interface RunFunction {
|
||||
(functionToRun: any): any;
|
||||
}
|
||||
export interface RunFunctionWithDescription {
|
||||
(description: string, functionToRun: any): any;
|
||||
}
|
||||
|
||||
export interface PauseFunction {
|
||||
(): any;
|
||||
}
|
||||
|
||||
export interface SleepFunction {
|
||||
(seconds: number): any;
|
||||
}
|
||||
|
||||
export interface Future {
|
||||
}
|
||||
|
||||
export interface testWindow {
|
||||
href(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface testLocation {
|
||||
url(): Future;
|
||||
path(): Future;
|
||||
search(): Future;
|
||||
hash(): Future;
|
||||
}
|
||||
|
||||
export interface Browser {
|
||||
navigateTo(url: string): void;
|
||||
navigateTo(urlDescription: string, urlFunction: () => string): void;
|
||||
reload(): void;
|
||||
window(): testWindow;
|
||||
location(): testLocation;
|
||||
}
|
||||
|
||||
export interface Matchers {
|
||||
toEqual(value: any): void;
|
||||
toBe(value: any): void;
|
||||
toBeDefined(): void;
|
||||
toBeTruthy(): void;
|
||||
toBeFalsy(): void;
|
||||
toMatch(regularExpression: any): void;
|
||||
toBeNull(): void;
|
||||
toContain(value: any): void;
|
||||
toBeLessThan(value: any): void;
|
||||
toBeGreaterThan(value: any): void;
|
||||
}
|
||||
|
||||
export interface CustomMatchers extends Matchers {
|
||||
}
|
||||
|
||||
export interface Expect extends CustomMatchers {
|
||||
not(): angularScenario.CustomMatchers;
|
||||
}
|
||||
|
||||
export interface UsingFunction {
|
||||
(selector: string, selectorDescription?: string): void;
|
||||
}
|
||||
|
||||
export interface BindingFunction {
|
||||
(bracketBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Input {
|
||||
enter(value: any): any;
|
||||
check(): any;
|
||||
select(radioButtonValue: any): any;
|
||||
val(): Future;
|
||||
}
|
||||
|
||||
export interface Repeater {
|
||||
count(): Future;
|
||||
row(index: number): Future;
|
||||
column(ngBindingExpression: string): Future;
|
||||
}
|
||||
|
||||
export interface Select {
|
||||
option(value: any): any;
|
||||
option(...listOfValues: any[]): any;
|
||||
}
|
||||
|
||||
export interface Element {
|
||||
count(): Future;
|
||||
click(): any;
|
||||
dblclick(): any;
|
||||
mouseover(): any;
|
||||
mousedown(): any;
|
||||
mouseup(): any;
|
||||
query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any;
|
||||
val(): Future;
|
||||
text(): Future;
|
||||
html(): Future;
|
||||
height(): Future;
|
||||
innerHeight(): Future;
|
||||
outerHeight(): Future;
|
||||
width(): Future;
|
||||
innerWidth(): Future;
|
||||
outerWidth(): Future;
|
||||
position(): Future;
|
||||
scrollLeft(): Future;
|
||||
scrollTop(): Future;
|
||||
offset(): Future;
|
||||
|
||||
val(value: any): void;
|
||||
text(value: any): void;
|
||||
html(value: any): void;
|
||||
height(value: any): void;
|
||||
innerHeight(value: any): void;
|
||||
outerHeight(value: any): void;
|
||||
width(value: any): void;
|
||||
innerWidth(value: any): void;
|
||||
outerWidth(value: any): void;
|
||||
position(value: any): void;
|
||||
scrollLeft(value: any): void;
|
||||
scrollTop(value: any): void;
|
||||
offset(value: any): void;
|
||||
|
||||
attr(key: any): Future;
|
||||
prop(key: any): Future;
|
||||
css(key: any): Future;
|
||||
|
||||
attr(key: any, value: any): void;
|
||||
prop(key: any, value: any): void;
|
||||
css(key: any, value: any): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare var describe: angularScenario.RunFunctionWithDescription;
|
||||
declare var ddescribe: angularScenario.RunFunctionWithDescription;
|
||||
declare var xdescribe: angularScenario.RunFunctionWithDescription;
|
||||
declare var beforeEach: angularScenario.RunFunction;
|
||||
declare var afterEach: angularScenario.RunFunction;
|
||||
declare var it: angularScenario.RunFunctionWithDescription;
|
||||
declare var iit: angularScenario.RunFunctionWithDescription;
|
||||
declare var xit: angularScenario.RunFunctionWithDescription;
|
||||
declare var pause: angularScenario.PauseFunction;
|
||||
declare var sleep: angularScenario.SleepFunction;
|
||||
declare function browser(): angularScenario.Browser;
|
||||
declare function expect(expectation: angularScenario.Future): angularScenario.Expect;
|
||||
declare var using: angularScenario.UsingFunction;
|
||||
declare var binding: angularScenario.BindingFunction;
|
||||
declare function input(ngModelBinding: string): angularScenario.Input;
|
||||
declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater;
|
||||
declare function select(ngModelBinding: string): angularScenario.Select;
|
||||
declare function element(selector: string, elementDescription?: string): angularScenario.Element;
|
||||
declare var angular: ng.IAngularStatic;
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-mocks-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typesSearchPaths": [
|
||||
"../"
|
||||
],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user