From c925818e13086e402f79fa49c39e012567d7b52a Mon Sep 17 00:00:00 2001 From: MG Date: Fri, 21 May 2021 06:57:05 +0200 Subject: [PATCH] fix(default-mock): supports generic type in array signature #583 --- libs/ng-mocks/src/lib/mock-helper/mock-helper.ts | 2 +- tests/issue-568/test.spec.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/ng-mocks/src/lib/mock-helper/mock-helper.ts b/libs/ng-mocks/src/lib/mock-helper/mock-helper.ts index 9ef2bfa433..5f82f5f7da 100644 --- a/libs/ng-mocks/src/lib/mock-helper/mock-helper.ts +++ b/libs/ng-mocks/src/lib/mock-helper/mock-helper.ts @@ -74,7 +74,7 @@ export const ngMocks: { * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock */ defaultMock( - defs: Array | InjectionToken>, + defs: Array | InjectionToken>, handler?: (value: undefined | T, injector: Injector) => undefined | Partial, ): void; diff --git a/tests/issue-568/test.spec.ts b/tests/issue-568/test.spec.ts index 2724474195..365d55a688 100644 --- a/tests/issue-568/test.spec.ts +++ b/tests/issue-568/test.spec.ts @@ -19,9 +19,12 @@ abstract class Service2 { const TOKEN = new InjectionToken<{ name: string }>('TOKEN'); -ngMocks.defaultMock([Service1, Service2, TOKEN], () => ({ - name: 'mock', -})); +ngMocks.defaultMock<{ name: string }>( + [Service1, Service2, TOKEN], + () => ({ + name: 'mock', + }), +); describe('issue-568', () => { describe('MockBuilder', () => {