@@ -26,7 +26,7 @@ import {
2626 getQueriesForElement ,
2727 queries as dtlQueries ,
2828} from '@testing-library/dom' ;
29- import { RenderComponentOptions , RenderDirectiveOptions , RenderTemplateOptions , RenderResult } from './models' ;
29+ import { RenderComponentOptions , RenderTemplateOptions , RenderResult } from './models' ;
3030import { getConfig } from './config' ;
3131
3232const mountedFixtures = new Set < ComponentFixture < any > > ( ) ;
@@ -36,24 +36,14 @@ export async function render<ComponentType>(
3636 component : Type < ComponentType > ,
3737 renderOptions ?: RenderComponentOptions < ComponentType > ,
3838) : 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 > > ;
4639export async function render < WrapperType = WrapperComponent > (
4740 template : string ,
4841 renderOptions ?: RenderTemplateOptions < WrapperType > ,
4942) : Promise < RenderResult < WrapperType > > ;
5043
5144export async function render < SutType , WrapperType = SutType > (
5245 sut : Type < SutType > | string ,
53- renderOptions :
54- | RenderComponentOptions < SutType >
55- | RenderDirectiveOptions < WrapperType >
56- | RenderTemplateOptions < WrapperType > = { } ,
46+ renderOptions : RenderComponentOptions < SutType > | RenderTemplateOptions < WrapperType > = { } ,
5747) : Promise < RenderResult < SutType > > {
5848 const { dom : domConfig , ...globalConfig } = getConfig ( ) ;
5949 const {
@@ -86,7 +76,6 @@ export async function render<SutType, WrapperType = SutType>(
8676 declarations : addAutoDeclarations ( sut , {
8777 declarations,
8878 excludeComponentDeclaration,
89- template,
9079 wrapper,
9180 } ) ,
9281 imports : addAutoImports ( {
@@ -106,7 +95,7 @@ export async function render<SutType, WrapperType = SutType>(
10695 TestBed . overrideProvider ( provide , provider ) ;
10796 } ) ;
10897
109- const componentContainer = createComponentFixture ( sut , { template , wrapper } ) ;
98+ const componentContainer = createComponentFixture ( sut , { wrapper } ) ;
11099
111100 let fixture : ComponentFixture < SutType > ;
112101 let detectChanges : ( ) => void ;
@@ -227,22 +216,18 @@ async function createComponent<SutType>(component: Type<SutType>): Promise<Compo
227216
228217function createComponentFixture < SutType > (
229218 sut : Type < SutType > | string ,
230- { template , wrapper } : Pick < RenderDirectiveOptions < any > , 'template' | 'wrapper' > ,
219+ { wrapper } : Pick < RenderTemplateOptions < SutType > , 'wrapper' > ,
231220) : Type < any > {
232221 if ( typeof sut === 'string' ) {
233222 TestBed . overrideTemplate ( wrapper , sut ) ;
234223 return wrapper ;
235224 }
236- if ( template ) {
237- TestBed . overrideTemplate ( wrapper , template ) ;
238- return wrapper ;
239- }
240225 return sut ;
241226}
242227
243228function setComponentProperties < SutType > (
244229 fixture : ComponentFixture < SutType > ,
245- { componentProperties = { } } : Pick < RenderDirectiveOptions < SutType , any > , 'componentProperties' > ,
230+ { componentProperties = { } } : Pick < RenderTemplateOptions < SutType , any > , 'componentProperties' > ,
246231) {
247232 for ( const key of Object . keys ( componentProperties ) ) {
248233 const descriptor : PropertyDescriptor = Object . getOwnPropertyDescriptor (
@@ -293,19 +278,15 @@ function addAutoDeclarations<SutType>(
293278 {
294279 declarations,
295280 excludeComponentDeclaration,
296- template,
297281 wrapper,
298- } : Pick < RenderDirectiveOptions < any > , 'declarations' | 'excludeComponentDeclaration' | 'template ' | 'wrapper' > ,
282+ } : Pick < RenderTemplateOptions < any > , 'declarations' | 'excludeComponentDeclaration' | 'wrapper' > ,
299283) {
300284 if ( typeof sut === 'string' ) {
301285 return [ ...declarations , wrapper ] ;
302286 }
303287
304- const wrappers = ( ) => ( template ? [ wrapper ] : [ ] ) ;
305-
306288 const components = ( ) => ( excludeComponentDeclaration ? [ ] : [ sut ] ) ;
307-
308- return [ ...declarations , ...wrappers ( ) , ...components ( ) ] ;
289+ return [ ...declarations , ...components ( ) ] ;
309290}
310291
311292function addAutoImports ( { imports, routes } : Pick < RenderComponentOptions < any > , 'imports' | 'routes' > ) {
0 commit comments