@@ -26,7 +26,7 @@ import {
26
26
getQueriesForElement ,
27
27
queries as dtlQueries ,
28
28
} from '@testing-library/dom' ;
29
- import { RenderComponentOptions , RenderDirectiveOptions , RenderTemplateOptions , RenderResult } from './models' ;
29
+ import { RenderComponentOptions , RenderTemplateOptions , RenderResult } from './models' ;
30
30
import { getConfig } from './config' ;
31
31
32
32
const mountedFixtures = new Set < ComponentFixture < any > > ( ) ;
@@ -36,24 +36,14 @@ export async function render<ComponentType>(
36
36
component : Type < ComponentType > ,
37
37
renderOptions ?: RenderComponentOptions < ComponentType > ,
38
38
) : Promise < RenderResult < ComponentType , ComponentType > > ;
39
- /**
40
- * @deprecated Use `render(template, { declarations: [DirectiveType] })` instead.
41
- */
42
- export async function render < DirectiveType , WrapperType = WrapperComponent > (
43
- component : Type < DirectiveType > ,
44
- renderOptions ?: RenderDirectiveOptions < WrapperType > ,
45
- ) : Promise < RenderResult < WrapperType > > ;
46
39
export async function render < WrapperType = WrapperComponent > (
47
40
template : string ,
48
41
renderOptions ?: RenderTemplateOptions < WrapperType > ,
49
42
) : Promise < RenderResult < WrapperType > > ;
50
43
51
44
export async function render < SutType , WrapperType = SutType > (
52
45
sut : Type < SutType > | string ,
53
- renderOptions :
54
- | RenderComponentOptions < SutType >
55
- | RenderDirectiveOptions < WrapperType >
56
- | RenderTemplateOptions < WrapperType > = { } ,
46
+ renderOptions : RenderComponentOptions < SutType > | RenderTemplateOptions < WrapperType > = { } ,
57
47
) : Promise < RenderResult < SutType > > {
58
48
const { dom : domConfig , ...globalConfig } = getConfig ( ) ;
59
49
const {
@@ -86,7 +76,6 @@ export async function render<SutType, WrapperType = SutType>(
86
76
declarations : addAutoDeclarations ( sut , {
87
77
declarations,
88
78
excludeComponentDeclaration,
89
- template,
90
79
wrapper,
91
80
} ) ,
92
81
imports : addAutoImports ( {
@@ -106,7 +95,7 @@ export async function render<SutType, WrapperType = SutType>(
106
95
TestBed . overrideProvider ( provide , provider ) ;
107
96
} ) ;
108
97
109
- const componentContainer = createComponentFixture ( sut , { template , wrapper } ) ;
98
+ const componentContainer = createComponentFixture ( sut , { wrapper } ) ;
110
99
111
100
let fixture : ComponentFixture < SutType > ;
112
101
let detectChanges : ( ) => void ;
@@ -227,22 +216,18 @@ async function createComponent<SutType>(component: Type<SutType>): Promise<Compo
227
216
228
217
function createComponentFixture < SutType > (
229
218
sut : Type < SutType > | string ,
230
- { template , wrapper } : Pick < RenderDirectiveOptions < any > , 'template' | 'wrapper' > ,
219
+ { wrapper } : Pick < RenderTemplateOptions < SutType > , 'wrapper' > ,
231
220
) : Type < any > {
232
221
if ( typeof sut === 'string' ) {
233
222
TestBed . overrideTemplate ( wrapper , sut ) ;
234
223
return wrapper ;
235
224
}
236
- if ( template ) {
237
- TestBed . overrideTemplate ( wrapper , template ) ;
238
- return wrapper ;
239
- }
240
225
return sut ;
241
226
}
242
227
243
228
function setComponentProperties < SutType > (
244
229
fixture : ComponentFixture < SutType > ,
245
- { componentProperties = { } } : Pick < RenderDirectiveOptions < SutType , any > , 'componentProperties' > ,
230
+ { componentProperties = { } } : Pick < RenderTemplateOptions < SutType , any > , 'componentProperties' > ,
246
231
) {
247
232
for ( const key of Object . keys ( componentProperties ) ) {
248
233
const descriptor : PropertyDescriptor = Object . getOwnPropertyDescriptor (
@@ -293,19 +278,15 @@ function addAutoDeclarations<SutType>(
293
278
{
294
279
declarations,
295
280
excludeComponentDeclaration,
296
- template,
297
281
wrapper,
298
- } : Pick < RenderDirectiveOptions < any > , 'declarations' | 'excludeComponentDeclaration' | 'template ' | 'wrapper' > ,
282
+ } : Pick < RenderTemplateOptions < any > , 'declarations' | 'excludeComponentDeclaration' | 'wrapper' > ,
299
283
) {
300
284
if ( typeof sut === 'string' ) {
301
285
return [ ...declarations , wrapper ] ;
302
286
}
303
287
304
- const wrappers = ( ) => ( template ? [ wrapper ] : [ ] ) ;
305
-
306
288
const components = ( ) => ( excludeComponentDeclaration ? [ ] : [ sut ] ) ;
307
-
308
- return [ ...declarations , ...wrappers ( ) , ...components ( ) ] ;
289
+ return [ ...declarations , ...components ( ) ] ;
309
290
}
310
291
311
292
function addAutoImports ( { imports, routes } : Pick < RenderComponentOptions < any > , 'imports' | 'routes' > ) {
0 commit comments