/** * @license * Copyright Google Inc. All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {Component, Directive, HostBinding, HostListener, Input, QueryList, ViewChildren} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {expect} from '@angular/platform-browser/testing/src/matchers'; import {ivyEnabled, onlyInIvy} from '@angular/private/testing'; describe('acceptance integration tests', () => { it('should only call inherited host listeners once', () => { let clicks = 0; @Component({template: ''}) class ButtonSuperClass { @HostListener('click') clicked() { clicks++; } } @Component({selector: 'button[custom-button]', template: ''}) class ButtonSubClass extends ButtonSuperClass { } @Component({template: ''}) class MyApp { } TestBed.configureTestingModule({declarations: [MyApp, ButtonSuperClass, ButtonSubClass]}); const fixture = TestBed.createComponent(MyApp); const button = fixture.debugElement.query(By.directive(ButtonSubClass)); fixture.detectChanges(); button.nativeElement.click(); fixture.detectChanges(); expect(clicks).toBe(1); }); it('should support inherited view queries', () => { @Directive({selector: '[someDir]'}) class SomeDir { } @Component({template: '
'}) class SuperComp { @ViewChildren(SomeDir) dirs !: QueryList