|
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 | +class TestComponent {} |
4 | 12 |
|
5 | 13 | class MockElementRef extends ElementRef {} |
6 | 14 |
|
7 | 15 | describe('ShadowOnScrollDirective', () => { |
| 16 | + let component: TestComponent; |
| 17 | + let fixture: ComponentFixture<TestComponent>; |
| 18 | + let debugElement: DebugElement; |
| 19 | + let document: 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', () => { |
|
0 commit comments