test(core): ngOnDestroy called before output events are detached (#9946)
closes #6984 closes #5436
This commit is contained in:
		
							parent
							
								
									1bd858fb43
								
							
						
					
					
						commit
						752edca81b
					
				| @ -84,6 +84,7 @@ export function main() { | ||||
|           CompWithRef, | ||||
|           EmitterDirective, | ||||
|           PushComp, | ||||
|           OnDestroyDirective, | ||||
|           OrderCheckDirective2, | ||||
|           OrderCheckDirective0, | ||||
|           OrderCheckDirective1, | ||||
| @ -1040,7 +1041,16 @@ export function main() { | ||||
|              ]); | ||||
|            })); | ||||
| 
 | ||||
|         it('should call ngOnDestory on pipes', fakeAsync(() => { | ||||
|         it('should deliver synchronous events to parent', fakeAsync(() => { | ||||
|              var ctx = createCompFixture('<div (destroy)="a=$event" onDestroyDirective></div>'); | ||||
| 
 | ||||
|              ctx.detectChanges(false); | ||||
|              ctx.destroy(); | ||||
| 
 | ||||
|              expect(ctx.componentInstance.a).toEqual('destroyed'); | ||||
|            })); | ||||
| 
 | ||||
|         it('should call ngOnDestroy on pipes', fakeAsync(() => { | ||||
|              var ctx = createCompFixture('{{true | pipeWithOnDestroy }}'); | ||||
| 
 | ||||
|              ctx.detectChanges(false); | ||||
| @ -1442,6 +1452,13 @@ class InjectableWithLifecycle { | ||||
|   ngOnDestroy() { this.log.add(this.name, 'ngOnDestroy'); } | ||||
| } | ||||
| 
 | ||||
| @Directive({selector: '[onDestroyDirective]'}) | ||||
| class OnDestroyDirective implements OnDestroy { | ||||
|   @Output('destroy') emitter = new EventEmitter<string>(false); | ||||
| 
 | ||||
|   ngOnDestroy() { this.emitter.emit('destroyed'); } | ||||
| } | ||||
| 
 | ||||
| @Directive({selector: '[orderCheck0]'}) | ||||
| class OrderCheckDirective0 { | ||||
|   private _name: string; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user