From 9e30ccf2e5f6cf69ade2537ff9033e8751ab0099 Mon Sep 17 00:00:00 2001 From: Jeremy Bell Date: Fri, 23 May 2014 17:47:07 -0400 Subject: [PATCH] Added overload to angular.mock.inject function to allow array-style dependency injection, which the function supports. Added test excercising the overload. --- angularjs/angular-mocks-tests.ts | 9 +++++++++ angularjs/angular-mocks.d.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/angularjs/angular-mocks-tests.ts b/angularjs/angular-mocks-tests.ts index b43580f36..b94c58f9e 100644 --- a/angularjs/angular-mocks-tests.ts +++ b/angularjs/angular-mocks-tests.ts @@ -21,6 +21,15 @@ mock.inject( function () { return 2; } ); +mock.inject( + ['$rootScope', function ($rootScope) { return 1; }]); + +// This overload is not documented on the website, but flows from +// how the injector works. +mock.inject( + ['$rootScope', function ($rootScope) { return 1; }], + ['$rootScope', function ($rootScope) { return 2; }]); + mock.module('module1', 'module2'); mock.module( function () { return 1; }, diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts index a607422dd..34b534a5e 100644 --- a/angularjs/angular-mocks.d.ts +++ b/angularjs/angular-mocks.d.ts @@ -30,6 +30,7 @@ declare module ng { // see http://docs.angularjs.org/api/angular.mock.inject inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works // see http://docs.angularjs.org/api/angular.mock.module module(...modules: string[]): any;