@@ -18,18 +18,11 @@ import {
18
18
configure as dtlConfigure ,
19
19
} from '@testing-library/dom' ;
20
20
import { RenderComponentOptions , RenderDirectiveOptions , RenderResult } from './models' ;
21
+ import { getConfig } from './config' ;
21
22
import { createSelectOptions , createType , tab } from './user-events' ;
22
23
23
24
const mountedFixtures = new Set < ComponentFixture < any > > ( ) ;
24
25
25
- dtlConfigure ( {
26
- eventWrapper : ( cb ) => {
27
- const result = cb ( ) ;
28
- detectChangesForMountedFixtures ( ) ;
29
- return result ;
30
- } ,
31
- } ) ;
32
-
33
26
export async function render < ComponentType > (
34
27
component : Type < ComponentType > ,
35
28
renderOptions ?: RenderComponentOptions < ComponentType > ,
@@ -59,9 +52,20 @@ export async function render<SutType, WrapperType = SutType>(
59
52
removeAngularAttributes = false ,
60
53
} = renderOptions as RenderDirectiveOptions < SutType , WrapperType > ;
61
54
55
+ const config = getConfig ( ) ;
56
+
57
+ dtlConfigure ( {
58
+ eventWrapper : ( cb ) => {
59
+ const result = cb ( ) ;
60
+ detectChangesForMountedFixtures ( ) ;
61
+ return result ;
62
+ } ,
63
+ ...config . dom ,
64
+ } ) ;
65
+
62
66
TestBed . configureTestingModule ( {
63
67
declarations : addAutoDeclarations ( sut , { declarations, excludeComponentDeclaration, template, wrapper } ) ,
64
- imports : addAutoImports ( { imports, routes } ) ,
68
+ imports : addAutoImports ( { imports : imports . concat ( config . defaultImports ) , routes } ) ,
65
69
providers : [ ...providers ] ,
66
70
schemas : [ ...schemas ] ,
67
71
} ) ;
@@ -102,7 +106,7 @@ export async function render<SutType, WrapperType = SutType>(
102
106
// Call ngOnChanges on initial render
103
107
if ( hasOnChangesHook ( fixture . componentInstance ) ) {
104
108
const changes = getChangesObj ( null , fixture . componentInstance ) ;
105
- fixture . componentInstance . ngOnChanges ( changes )
109
+ fixture . componentInstance . ngOnChanges ( changes ) ;
106
110
}
107
111
108
112
if ( detectChangesOnRender ) {
@@ -224,20 +228,21 @@ function setComponentProperties<SutType>(
224
228
}
225
229
226
230
function hasOnChangesHook < SutType > ( componentInstance : SutType ) : componentInstance is SutType & OnChanges {
227
- return 'ngOnChanges' in componentInstance
228
- && typeof ( componentInstance as SutType & OnChanges ) . ngOnChanges === 'function' ;
229
- } ;
231
+ return (
232
+ 'ngOnChanges' in componentInstance && typeof ( componentInstance as SutType & OnChanges ) . ngOnChanges === 'function'
233
+ ) ;
234
+ }
230
235
231
- function getChangesObj < SutType > (
232
- oldProps : Partial < SutType > | null ,
233
- newProps : Partial < SutType >
234
- ) {
236
+ function getChangesObj < SutType > ( oldProps : Partial < SutType > | null , newProps : Partial < SutType > ) {
235
237
const isFirstChange = oldProps === null ;
236
- return Object . keys ( newProps ) . reduce < SimpleChanges > ( ( changes , key ) => ( {
237
- ...changes ,
238
- [ key ] : new SimpleChange ( isFirstChange ? null : oldProps [ key ] , newProps [ key ] , isFirstChange )
239
- } ) , { } ) ;
240
- } ;
238
+ return Object . keys ( newProps ) . reduce < SimpleChanges > (
239
+ ( changes , key ) => ( {
240
+ ...changes ,
241
+ [ key ] : new SimpleChange ( isFirstChange ? null : oldProps [ key ] , newProps [ key ] , isFirstChange ) ,
242
+ } ) ,
243
+ { } ,
244
+ ) ;
245
+ }
241
246
242
247
function addAutoDeclarations < SutType > (
243
248
component : Type < SutType > ,
@@ -425,7 +430,6 @@ const userEvent = {
425
430
*/
426
431
export {
427
432
buildQueries ,
428
- configure ,
429
433
getByLabelText ,
430
434
getAllByLabelText ,
431
435
queryByLabelText ,
0 commit comments