Skip to content

Commit

Permalink
Merge pull request #584 from satanTime/issues/583
Browse files Browse the repository at this point in the history
fix(default-mock): supports generic type in array signature #583
  • Loading branch information
satanTime authored May 21, 2021
2 parents fad3a89 + c925818 commit 2efa2e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libs/ng-mocks/src/lib/mock-helper/mock-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const ngMocks: {
* @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock
*/
defaultMock<T = any>(
defs: Array<AnyType<any> | InjectionToken<any>>,
defs: Array<AnyType<T> | InjectionToken<T>>,
handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>,
): void;

Expand Down
9 changes: 6 additions & 3 deletions tests/issue-568/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 2efa2e6

Please sign in to comment.