All files / src/lib/wvr-message-manifest/wvr-message-manifest-entry wvr-message-manifest-entry.component.ts

88.89% Statements 8/9
50% Branches 1/2
100% Functions 2/2
87.5% Lines 7/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                    1x                                               11x 11x           8x 8x 8x 8x              
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit } from '@angular/core';
import { ComponentRegistryService } from '../../core/component-registry.service';
import { WvrBaseComponent } from '../../shared/wvr-base.component';
import { WvrMessageManifestComponent } from '../wvr-message-manifest.component';
 
@Component({
  selector: 'wvr-message-manifest-entry-component',
  template: '',
  changeDetection: ChangeDetectionStrategy.Default
})
export class WvrMessageManifestEntryComponent implements OnInit {
 
  /** The name by which this message manifest entry can be referenced. */
  @Input() name;
 
  /** A human description of this manifes. */
  @Input() description;
 
  /** The destination to connect to. */
  @Input() destination;
 
  /** The protocol to use. */
  @Input() protocol;
 
  /** Additional configuration options. */
  @Input() options;
 
  /** The strategy to be employed to unwrap response data. */
  @Input() mappingStrategy;
 
  /** A collection of the child WvrMessageManifestEntryComponent. */
  private parent: WvrMessageManifestComponent;
 
  constructor(
    private readonly eRef: ElementRef<HTMLElement>,
    private readonly componentRegistry: ComponentRegistryService<WvrBaseComponent>
  ) {
 
  }
 
  ngOnInit(): void {
    const parentElem = this.eRef.nativeElement.closest('wvre-message-manifest, wvr-message-manifest-component');
    Eif (parentElem) {
      this.parent = this.componentRegistry.getComponentByElement(parentElem as HTMLElement) as WvrMessageManifestComponent;
      this.parent.addEntry(this);
    } else {
      console.warn(`WvrMessageManifestEntryComponent ${this.name} is not contained with a WvrMessageManifestComponent`);
    }
  }
 
}