All files / src/app/shared/components/product/product-name product-name.component.ts

100% Statements 12/12
70% Branches 7/10
100% Functions 2/2
100% Lines 12/12

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 3613x 13x     13x             13x 5x   5x                 5x 5x       5x 5x 5x   5x      
import { ChangeDetectionStrategy, Component, Inject, Input, OnInit, Optional } from '@angular/core';
import { QueryParamsHandling } from '@angular/router';
import { Observable } from 'rxjs';
 
import { ProductContextFacade } from 'ish-core/facades/product-context.facade';
 
@Component({
  selector: 'ish-product-name',
  templateUrl: './product-name.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ProductNameComponent implements OnInit {
  @Input() link = true;
  @Input() alternate: string;
  @Input() queryParamsHandling: QueryParamsHandling = '';
 
  productName$: Observable<string>;
  productURL$: Observable<string>;
  visible$: Observable<boolean>;
 
  computedQueryParamsHandling: QueryParamsHandling;
 
  constructor(
    private context: ProductContextFacade,
    @Optional() @Inject('PRODUCT_QUERY_PARAMS_HANDLING') private queryParamsHandlingInjector: QueryParamsHandling
  ) {}
 
  ngOnInit() {
    this.productName$ = this.context.select('product', 'name');
    this.productURL$ = this.context.select('productURL');
    this.visible$ = this.context.select('displayProperties', 'name');
 
    this.computedQueryParamsHandling = this.queryParamsHandlingInjector ?? this.queryParamsHandling;
  }
}