@@ -232,7 +232,15 @@ export function main() {
232232
233233 } ) ;
234234
235- describe ( 'recurse into static child component views' , ( ) => {
235+ describe ( 'recursively destroy dynamic child component views' , ( ) => {
236+ // TODO
237+ } ) ;
238+
239+ } ) ;
240+
241+ describe ( 'static child components' , ( ) => {
242+
243+ describe ( 'recursively create when not cached' , ( ) => {
236244 var hostView , componentProtoView , nestedProtoView ;
237245 beforeEach ( ( ) => {
238246 hostView = createView ( createProtoView (
@@ -267,19 +275,16 @@ export function main() {
267275 expect ( renderer . spy ( 'setEventDispatcher' ) ) . toHaveBeenCalledWith ( cmpView . render , cmpView ) ;
268276 } ) ;
269277 } ) ;
270- } ) ;
271278
272- describe ( 'createDynamicComponentView' , ( ) => {
273- // TODO: implement this!
274- describe ( 'recurse into static child component views' , ( ) => {
275- // TODO
279+ describe ( 'recursively hydrate when getting from from the cache' , ( ) => {
280+ // TODO(tbosch): implement this
276281 } ) ;
277282
278- describe ( 'recurse into dynamic child component views ' , ( ) => {
279- // TODO
283+ describe ( 'recursively dehydrate ' , ( ) => {
284+ // TODO(tbosch): implement this
280285 } ) ;
281- } ) ;
282286
287+ } ) ;
283288
284289 describe ( 'createInPlaceHostView' , ( ) => {
285290
@@ -347,9 +352,14 @@ export function main() {
347352 hostRenderViewRef = hostView . render ;
348353 } ) ;
349354
350- it ( 'should dehydrateAndDetach' , ( ) => {
355+ it ( 'should dehydrate' , ( ) => {
356+ manager . destroyInPlaceHostView ( elementRef ( parentHostView , 0 ) , hostView ) ;
357+ expect ( utils . spy ( 'detachInPlaceHostView' ) ) . toHaveBeenCalledWith ( parentView , hostView ) ;
358+ } ) ;
359+
360+ it ( 'should detach' , ( ) => {
351361 manager . destroyInPlaceHostView ( elementRef ( parentHostView , 0 ) , hostView ) ;
352- expect ( utils . spy ( 'dehydrateAndDetachInPlaceHostView ' ) ) . toHaveBeenCalledWith ( parentView , hostView ) ;
362+ expect ( utils . spy ( 'dehydrateView ' ) ) . toHaveBeenCalledWith ( hostView ) ;
353363 } ) ;
354364
355365 it ( 'should destroy and clear the render view' , ( ) => {
@@ -364,17 +374,14 @@ export function main() {
364374 } ) ;
365375 } ) ;
366376
367- describe ( 'recurse into imperativeHostViews ' , ( ) => {
377+ describe ( 'recursively destroy inPlaceHostViews ' , ( ) => {
368378 // TODO
369379 } ) ;
370380
371381 } ) ;
372382
373383 describe ( 'createViewInContainer' , ( ) => {
374384
375- // Note: We don't add tests for recursion or viewpool here as we assume that
376- // this is using the same mechanism as the other methods...
377-
378385 describe ( 'basic functionality' , ( ) => {
379386 var parentView , childProtoView ;
380387 beforeEach ( ( ) => {
@@ -425,8 +432,6 @@ export function main() {
425432 } ) ;
426433
427434 describe ( 'destroyViewInContainer' , ( ) => {
428- // Note: We don't add tests for recursion here as we assume that
429- // this is using the same mechanism as the other methods...
430435
431436 describe ( 'basic functionality' , ( ) => {
432437 var parentView , childProtoView , childView ;
@@ -461,8 +466,38 @@ export function main() {
461466 } ) ;
462467 } ) ;
463468
464- describe ( 'recurse into ViewContainers' , ( ) => {
465- // TODO
469+ describe ( 'recursively destroy views in ViewContainers' , ( ) => {
470+ var parentView , childProtoView , childView ;
471+ beforeEach ( ( ) => {
472+ parentView = createView ( createProtoView (
473+ [ createEmptyElBinder ( ) ]
474+ ) ) ;
475+ parentView . render = new ViewRef ( ) ;
476+ childProtoView = createProtoView ( ) ;
477+ childView = manager . createViewInContainer ( elementRef ( parentView , 0 ) , 0 , childProtoView , null ) ;
478+ } ) ;
479+
480+ it ( 'should dehydrate' , ( ) => {
481+ manager . destroyInPlaceHostView ( null , parentView ) ;
482+ expect ( utils . spy ( 'dehydrateView' ) ) . toHaveBeenCalledWith ( parentView . viewContainers [ 0 ] . views [ 0 ] ) ;
483+ } ) ;
484+
485+ it ( 'should detach' , ( ) => {
486+ manager . destroyInPlaceHostView ( null , parentView ) ;
487+ expect ( utils . spy ( 'detachViewInContainer' ) ) . toHaveBeenCalledWith ( parentView , 0 , 0 ) ;
488+ } ) ;
489+
490+ it ( 'should not destroy but clear the render view' , ( ) => {
491+ manager . destroyInPlaceHostView ( null , parentView ) ;
492+ expect ( renderer . spy ( 'destroyViewInContainer' ) ) . not . toHaveBeenCalled ( ) ;
493+ expect ( childView . render ) . toBe ( null ) ;
494+ } ) ;
495+
496+ it ( 'should return the view to the pool' , ( ) => {
497+ manager . destroyInPlaceHostView ( null , parentView ) ;
498+ expect ( viewPool . spy ( 'returnView' ) ) . toHaveBeenCalledWith ( childView ) ;
499+ } ) ;
500+
466501 } ) ;
467502
468503 } ) ;
0 commit comments