diff --git a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.html b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.html index a1b75c582f..8115a5706f 100644 --- a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.html +++ b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.html @@ -44,7 +44,7 @@ - +
{{ 'checkout.cart.payment_cost.label' | translate }}
{{ totals.paymentCostsTotal | ishPrice }}
diff --git a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.spec.ts b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.spec.ts index dffed032e8..bb0909d1e3 100644 --- a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.spec.ts +++ b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.spec.ts @@ -75,13 +75,28 @@ describe('Basket Cost Summary Component', () => { `); })); - it('should not display estimated prices if estimated flag is not set', () => { + it('should not display estimated prices if estimated flag is not set', fakeAsync(() => { fixture.detectChanges(); + tick(500); + expect(element.querySelector('.total-price').textContent.trim()).toEqual('checkout.order.total_cost.label'); - }); - it('should display estimated prices if estimated flag is set', () => { + })); + it('should display estimated prices if estimated flag is set', fakeAsync(() => { component.totals.isEstimated = true; fixture.detectChanges(); + tick(500); + expect(element.querySelector('.total-price').textContent.trim()).toEqual('checkout.cart.estimated_total.label'); - }); + })); + + it('should not display paymentCostsTotal when value is zero', fakeAsync(() => { + component.totals = { + ...BasketMockData.getTotals(), + paymentCostsTotal: { type: 'PriceItem', currency: 'USD', gross: 0.0, net: 0.0 }, + }; + fixture.detectChanges(); + tick(500); + + expect(element.textContent).not.toContain('checkout.cart.payment_cost.label'); + })); }); diff --git a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.ts b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.ts index 15c9afb399..1338ef6a37 100644 --- a/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.ts +++ b/src/app/shared/components/basket/basket-cost-summary/basket-cost-summary.component.ts @@ -4,6 +4,7 @@ import { map } from 'rxjs/operators'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { BasketTotal } from 'ish-core/models/basket-total/basket-total.model'; +import { PriceItemHelper } from 'ish-core/models/price-item/price-item.helper'; import { PriceHelper } from 'ish-core/models/price/price.model'; /** @@ -32,4 +33,9 @@ export class BasketCostSummaryComponent implements OnInit { map(type => (type === 'net' ? 'checkout.tax.text' : 'checkout.tax.TaxesLabel.TotalOrderVat')) ); } + + get hasPaymentCostsTotal(): boolean { + const paymentCosts = PriceItemHelper.selectType(this.totals && this.totals.paymentCostsTotal, 'gross'); + return !!paymentCosts && !!paymentCosts.value; + } }