diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts index 63ea220f6..86bbe6c94 100644 --- a/angularjs/angular-mocks-tests.ts +++ b/angularjs/angular-mocks-tests.ts @@ -87,6 +87,16 @@ logCall = logService.warn; logs = logCall.logs; +/////////////////////////////////////// +// IComponentControllerService +/////////////////////////////////////// +var $componentController: ng.IComponentControllerService; +$componentController<{}, {}>('Test controller', { $scope: {} }); +$componentController<{}, {}>('Test controller', { $scope: {}, test: true }); +$componentController<{}, { test: boolean }>('Test controller', { $scope: {} }, { test: true}); +$componentController<{}, { test?: boolean }>('Test controller', { $scope: {} }, {}); +$componentController<{}, {}>('Test controller', { $scope: {} }, {}, 'identity'); +$componentController<{ cb: () => void }, {}>('Test controller', { $scope: {} }); /////////////////////////////////////// // IHttpBackendService diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index ade823572..429c7b526 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -97,6 +97,17 @@ declare namespace angular { logs: string[]; } + /////////////////////////////////////////////////////////////////////////// + // 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 + (componentName: string, locals: { $scope: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T; + } + + /////////////////////////////////////////////////////////////////////////// // HttpBackendService // see https://docs.angularjs.org/api/ngMock/service/$httpBackend