Add ControllerService to angular-mocks (#8889)

* Add ControllerService to angular-mocks

The definition in angular.d.ts changed that used to included this definition.
Needed because of 69d2fb9

* Added unit tests for controller service mock
This commit is contained in:
Anthony Ciccarello
2016-04-12 22:42:42 +09:00
committed by Masahiro Wakame
parent 3e03f67efe
commit 0ea6c46516
2 changed files with 21 additions and 0 deletions
+9
View File
@@ -87,6 +87,15 @@ 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
///////////////////////////////////////
+12
View File
@@ -97,6 +97,18 @@ declare namespace angular {
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