All files / src/app/shared/components/basket/basket-promotion basket-promotion.component.ts

100% Statements 7/7
80% Branches 4/5
100% Functions 2/2
100% Lines 7/7

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 261x     1x 1x               1x         3x     3x 2x        
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { Observable } from 'rxjs';
 
import { ShoppingFacade } from 'ish-core/facades/shopping.facade';
import { BasketRebate } from 'ish-core/models/basket-rebate/basket-rebate.model';
import { Promotion } from 'ish-core/models/promotion/promotion.model';
 
@Component({
  selector: 'ish-basket-promotion',
  templateUrl: './basket-promotion.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class BasketPromotionComponent implements OnChanges {
  @Input({ required: true }) rebate: BasketRebate;
 
  promotion$: Observable<Promotion>;
 
  constructor(private shoppingFacade: ShoppingFacade) {}
 
  ngOnChanges() {
    if (this.rebate?.promotionId) {
      this.promotion$ = this.shoppingFacade.promotion$(this.rebate.promotionId);
    }
  }
}