import { ComponentTester } from './component-tester' ; import { TestButton } from './test-button' ; import { TestSelect } from './test-select' ; import { TestTextArea } from './test-textarea' ; import { TestInput } from './test-input' ; import { TestElementQuerier } from './test-element-querier' ; import { DebugElement } from '@angular/core' ; import { TestHtmlElement } from './test-html-element' ; /**
 * A wrapped DOM element, providing additional methods and attributes helping with writing tests
 */ export class TestElement < E extends Element = Element > { private querier : TestElementQuerier ; constructor ( protected tester , /**
     * the wrapped debug element
     */ readonly debugElement ) { this . querier = new TestElementQuerier ( tester , debugElement ) ; } get nativeElement ( ) : E { return this . debugElement . nativeElement ; } /**
     * the text content of this element
     */ get textContent ( ) : string | null { return this . nativeElement . textContent ; } /**
     * dispatches an event of the given type from the wrapped element, then triggers a change detection
     */ dispatchEventOfType ( type ) { this . nativeElement . dispatchEvent ( new Event ( type ) ) ; this . tester . detectChanges ( ) ; } /**
     * dispatches the given event from the wrapped element, then triggers a change detection
     */ dispatchEvent ( event ) { this . nativeElement . dispatchEvent ( event ) ; this . tester . detectChanges ( ) ; } /**
     * Gets the CSS classes of the wrapped element, as an array
     */ get classes ( ) : Array < string > { return Array . prototype . slice . call ( this . nativeElement . classList ) ; } param name attr ( name ) { return this . nativeElement . getAttribute ( name ) ; } param selector returns element < K extends keyof HTMLElementTagNameMap > ( selector ) ; param selector returns element < K extends keyof SVGElementTagNameMap > ( selector ) ; param selector returns element ( selector ) ; param selector returns element < T extends HTMLInputElement > ( selector ) ; param selector returns element < T extends HTMLTextAreaElement > ( selector ) ; param selector returns element < T extends HTMLSelectElement > ( selector ) ; param selector returns element < T extends HTMLButtonElement > ( selector ) ; param selector returns element < T extends HTMLElement > ( selector ) ; param selector returns element < T extends Element > ( selector ) ; element ( selector ) { return this . querier . element ( selector ) ; } param selector returns elements < K extends keyof HTMLElementTagNameMap > ( selector ) ; param selector returns elements < K extends keyof SVGElementTagNameMap > ( selector ) ; param selector returns elements ( selector ) ; param selector returns elements < T extends HTMLInputElement > ( selector ) ; param selector returns elements < T extends HTMLTextAreaElement > ( selector ) ; param selector returns elements < T extends HTMLButtonElement > ( selector ) ; param selector returns elements < T extends HTMLSelectElement > ( selector ) ; param selector returns elements < T extends HTMLElement > ( selector ) ; param selector returns elements < T extends Element > ( selector ) ; elements ( selector ) { return this . querier . elements ( selector ) ; } param selector returns input ( selector ) { return this . querier . input ( selector ) ; } param selector returns select ( selector ) { return this . querier . select ( selector ) ; } param selector returns throws textarea ( selector ) { return this . querier . textarea ( selector ) ; } param selector returns button ( selector ) { return this . querier . button ( selector ) ; } }