Example of how to test a directive.
/* tslint:disable:no-unused-variable */
import { Component } from '@angular/core';
import { TestBed, async } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DisableParentScrollDirective } from './disable-parent-scroll.directive';
@Component({
template: `
<div style="height: 100px;">
<div adminDisableParentScroll>
<div style="height:400px;"></div>
</div>
</div>`,
})
class TestComponent { }
describe(`DisableParentScrollDirective`, () => {
let fixture;
let instances;
let element;
beforeEach(() => {
fixture = TestBed.configureTestingModule({
declarations: [
DisableParentScrollDirective,
TestComponent,
],
})
.createComponent(TestComponent);
fixture.detectChanges();
instances = fixture.debugElement.queryAll(By.directive(DisableParentScrollDirective));
element = fixture.nativeElement;
});
it(`should create an instance`, () => {
expect(instances.length).toBe(1);
});
});