refactor(ivy): move di tests for inject to acceptance (#29299)
PR Close #29299
This commit is contained in:
		
							parent
							
								
									0151ad432b
								
							
						
					
					
						commit
						c99d379cc8
					
				| @ -860,6 +860,47 @@ describe('di', () => { | |||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|  |   describe('inject', () => { | ||||||
|  | 
 | ||||||
|  |     it('should inject from parent view', () => { | ||||||
|  |       @Directive({selector: '[parentDir]'}) | ||||||
|  |       class ParentDirective { | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       @Directive({selector: '[childDir]', exportAs: 'childDir'}) | ||||||
|  |       class ChildDirective { | ||||||
|  |         value: string; | ||||||
|  |         constructor(public parent: ParentDirective) { this.value = parent.constructor.name; } | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       @Directive({selector: '[child2Dir]', exportAs: 'child2Dir'}) | ||||||
|  |       class Child2Directive { | ||||||
|  |         value: boolean; | ||||||
|  |         constructor(parent: ParentDirective, child: ChildDirective) { | ||||||
|  |           this.value = parent === child.parent; | ||||||
|  |         } | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       @Component({ | ||||||
|  |         template: `<div parentDir>
 | ||||||
|  |           <ng-container *ngIf="showing"> | ||||||
|  |             <span childDir child2Dir #child1="childDir" #child2="child2Dir">{{ child1.value }}-{{ child2.value }}</span> | ||||||
|  |           </ng-container> | ||||||
|  |         </div>` | ||||||
|  |       }) | ||||||
|  |       class MyComp { | ||||||
|  |         showing = true; | ||||||
|  |       } | ||||||
|  |       TestBed.configureTestingModule( | ||||||
|  |           {declarations: [ParentDirective, ChildDirective, Child2Directive, MyComp]}); | ||||||
|  |       const fixture = TestBed.createComponent(MyComp); | ||||||
|  |       fixture.detectChanges(); | ||||||
|  | 
 | ||||||
|  |       const divElement = fixture.nativeElement.querySelector('div'); | ||||||
|  |       expect(divElement.textContent).toBe('ParentDirective-true'); | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|   describe('Special tokens', () => { |   describe('Special tokens', () => { | ||||||
| 
 | 
 | ||||||
|     describe('Injector', () => { |     describe('Injector', () => { | ||||||
|  | |||||||
| @ -526,6 +526,9 @@ describe('di', () => { | |||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * This test needs to be moved to acceptance/di_spec.ts when Ivy compiler supports inline views. | ||||||
|  |      */ | ||||||
|     it('should inject from parent view', () => { |     it('should inject from parent view', () => { | ||||||
|       const ParentDirective = createDirective('parentDir'); |       const ParentDirective = createDirective('parentDir'); | ||||||
| 
 | 
 | ||||||
| @ -593,10 +596,6 @@ describe('di', () => { | |||||||
|       expect(fixture.html) |       expect(fixture.html) | ||||||
|           .toEqual('<div parentdir=""><span child2dir="" childdir="">Directive-true</span></div>'); |           .toEqual('<div parentdir=""><span child2dir="" childdir="">Directive-true</span></div>'); | ||||||
|     }); |     }); | ||||||
| 
 |  | ||||||
|     it('should inject from module Injector', () => { |  | ||||||
| 
 |  | ||||||
|                                              }); |  | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   describe('getOrCreateNodeInjector', () => { |   describe('getOrCreateNodeInjector', () => { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user