|
1 | | -import{ElementRef}from'@angular/core'; |
2 | | -import{TestBed}from'@angular/core/testing'; |
| 1 | +import{Component,DebugElement,ElementRef}from'@angular/core'; |
| 2 | +import{ComponentFixture,TestBed}from'@angular/core/testing'; |
3 | 3 | import{ShadowOnScrollDirective}from'./shadow-on-scroll.directive'; |
| 4 | +import{By}from'@angular/platform-browser'; |
| 5 | +import{DOCUMENT}from'@angular/common'; |
| 6 | + |
| 7 | +@Component({ |
| 8 | +imports:[ShadowOnScrollDirective], |
| 9 | +template:'<div cShadowOnScroll></div>' |
| 10 | +}) |
| 11 | +classTestComponent{} |
4 | 12 |
|
5 | 13 | classMockElementRefextendsElementRef{} |
6 | 14 |
|
7 | 15 | describe('ShadowOnScrollDirective',()=>{ |
| 16 | +letcomponent:TestComponent; |
| 17 | +letfixture:ComponentFixture<TestComponent>; |
| 18 | +letdebugElement:DebugElement; |
| 19 | +letdocument:Document; |
8 | 20 |
|
9 | 21 | beforeEach(()=>{ |
10 | 22 | TestBed.configureTestingModule({ |
11 | | -imports:[ShadowOnScrollDirective], |
| 23 | +imports:[TestComponent,ShadowOnScrollDirective], |
12 | 24 | providers:[{provide:ElementRef,useClass:MockElementRef}] |
13 | | -}); |
| 25 | +}).compileComponents(); |
| 26 | + |
| 27 | +fixture=TestBed.createComponent(TestComponent); |
| 28 | +document=TestBed.inject(DOCUMENT); |
| 29 | +component=fixture.componentInstance; |
| 30 | +debugElement=fixture.debugElement.query(By.directive(ShadowOnScrollDirective)); |
| 31 | +fixture.detectChanges(); |
14 | 32 | }); |
15 | 33 |
|
16 | 34 | it('should create an instance',()=>{ |
|