@@ -6,26 +6,35 @@ import { HostComponentService } from './host-component.service';
6
6
import { HostDirectiveService } from './host-directive.service' ;
7
7
import { NgxTestingModule } from './ngx-testing.module' ;
8
8
import {
9
+ ComponentInputs ,
9
10
TestingComponentModuleExtras ,
10
11
TestingDirectiveModuleExtras ,
11
12
} from './types' ;
12
13
13
14
export interface TestingFactory < T , H extends Host > {
14
15
testModule : NgxTestingModule < T > ;
15
16
getHost ( ) : H ;
16
- createComponent ( ) : Promise < H > ;
17
+ createComponent (
18
+ inputs ?: ComponentInputs < T > ,
19
+ detectChanges ?: boolean ,
20
+ ) : Promise < H > ;
17
21
}
18
22
19
23
export function getTestingForComponent < T > (
20
24
type : Type < T > ,
21
25
extras ?: TestingComponentModuleExtras ,
22
26
) : TestingFactory < T , HostComponentService < T > > {
23
27
const testModule = NgxTestingModule . forComponent < T > ( type , extras ) ;
28
+
24
29
const getHost = ( ) =>
25
- TestBed . get ( HostComponentService ) as HostComponentService < T > ;
26
- const createComponent = ( ) =>
30
+ TestBed . inject ( HostComponentService ) as HostComponentService < T > ;
31
+
32
+ const createComponent = (
33
+ inputs ?: ComponentInputs < T > ,
34
+ detectChanges ?: boolean ,
35
+ ) =>
27
36
getHost ( )
28
- . createComponent ( )
37
+ . createComponent ( inputs , detectChanges )
29
38
. then ( getHost ) ;
30
39
31
40
return { testModule, getHost, createComponent } ;
@@ -36,11 +45,16 @@ export function getTestingForDirective<T>(
36
45
extras ?: TestingDirectiveModuleExtras ,
37
46
) : TestingFactory < T , HostDirectiveService < T > > {
38
47
const testModule = NgxTestingModule . forDirective < T > ( type , extras ) ;
48
+
39
49
const getHost = ( ) =>
40
- TestBed . get ( HostDirectiveService ) as HostDirectiveService < T > ;
41
- const createComponent = ( ) =>
50
+ TestBed . inject ( HostDirectiveService ) as HostDirectiveService < T > ;
51
+
52
+ const createComponent = (
53
+ inputs ?: ComponentInputs < T > ,
54
+ detectChanges ?: boolean ,
55
+ ) =>
42
56
getHost ( )
43
- . createComponent ( )
57
+ . createComponent ( inputs , detectChanges )
44
58
. then ( getHost ) ;
45
59
46
60
return { testModule, getHost, createComponent } ;
0 commit comments