Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="child" (click)="testClick($event)"></div>
- testClick(event) {
- console.log(event);
- }
- describe('AppComponent', () => {
- let fixture: ComponentFixture<AppComponent>;
- let app: AppComponent;
- let child: DebugElement;
- beforeEach(async(() => {
- TestBed.configureTestingModule({
- imports: [ ChildModule ],
- declarations: [
- AppComponent
- ],
- }).compileComponents();
- }));
- beforeEach(() => {
- fixture = TestBed.createComponent(AppComponent);
- app = fixture.debugElement.componentInstance;
- child = fixture.debugElement.query(By.css('.child'));
- fixture.detectChanges();
- });
- it(`should create the handle of the joystick'`, async(() => {
- expect(child).toBeTruthy();
- }));
- it(`clicks on the joystick handle and the relative Observable emits`, async(() => {
- setTimeout(() => {
- childHandle.triggerEventHandler('click', 'clicked');
- }, 100);
- }));
- });
- export class ChildComponent implements AfterViewInit {
- @ViewChild('child') private childElement: ElementRef;
- ngAfterViewInit() {
- const testClick$ = fromEvent(this.childElement.nativeElement, 'click');
- testClick$.subscribe(d => console.log('test click in child', d));
- }
- }
Add Comment
Please, Sign In to add comment