Skip to content

Commit

Permalink
fix(factories): allow to pass extras to testing module
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Malkevich committed Jan 7, 2019
1 parent 3a636d8 commit e1979cb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions projects/ngx-testing/src/lib/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import { Host } from './host';
import { HostComponentService } from './host-component.service';
import { HostDirectiveService } from './host-directive.service';
import { NgxTestingModule } from './ngx-testing.module';
import {
TestingComponentModuleExtras,
TestingDirectiveModuleExtras,
} from './types';

export interface TestingFactory<T, H extends Host> {
testModule: NgxTestingModule<T>;
Expand All @@ -14,8 +18,9 @@ export interface TestingFactory<T, H extends Host> {

export function getTestingForComponent<T>(
type: Type<T>,
extras?: TestingComponentModuleExtras,
): TestingFactory<T, HostComponentService<T>> {
const testModule = NgxTestingModule.forComponent<T>(type);
const testModule = NgxTestingModule.forComponent<T>(type, extras);
const getHost = () =>
TestBed.get(HostComponentService) as HostComponentService<T>;
const createComponent = () =>
Expand All @@ -28,8 +33,9 @@ export function getTestingForComponent<T>(

export function getTestingForDirective<T>(
type: Type<T>,
extras?: TestingDirectiveModuleExtras,
): TestingFactory<T, HostDirectiveService<T>> {
const testModule = NgxTestingModule.forDirective<T>(type);
const testModule = NgxTestingModule.forDirective<T>(type, extras);
const getHost = () =>
TestBed.get(HostDirectiveService) as HostDirectiveService<T>;
const createComponent = () =>
Expand Down

0 comments on commit e1979cb

Please sign in to comment.