All files / src/app/extensions/wishlists/shared/wishlist-line-item wishlist-line-item.component.ts

60% Statements 6/10
50% Branches 3/6
33.33% Functions 1/3
60% Lines 6/10

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 331x   1x 1x                   1x 1x       1x                            
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
 
import { WishlistsFacade } from '../../facades/wishlists.facade';
import { Wishlist, WishlistItem } from '../../models/wishlist/wishlist.model';
 
/**
 * The Wishlist item component displays a wishlist item. This Item can be removed or moved to another wishlist.
 */
@Component({
  selector: 'ish-wishlist-line-item',
  templateUrl: './wishlist-line-item.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WishlistLineItemComponent {
  constructor(private wishlistsFacade: WishlistsFacade) {}
 
  @Input({ required: true }) wishlistItemData: WishlistItem;
  @Input({ required: true }) currentWishlist: Wishlist;
  @Input() readOnly = false;
 
  moveItemToOtherWishlist(sku: string, wishlistMoveData: { id: string; title: string }) {
    if (wishlistMoveData.id) {
      this.wishlistsFacade.moveItemToWishlist(this.currentWishlist.id, wishlistMoveData.id, sku);
    } else {
      this.wishlistsFacade.moveItemToNewWishlist(this.currentWishlist.id, wishlistMoveData.title, sku);
    }
  }
 
  removeProductFromWishlist(sku: string) {
    this.wishlistsFacade.removeProductFromWishlist(this.currentWishlist.id, sku);
  }
}