Skip to content

Commit

Permalink
fix: suppress display of total payment costs with zero value on cost …
Browse files Browse the repository at this point in the history
…summary
  • Loading branch information
dhhyi committed Apr 28, 2020
1 parent 910e643 commit 67fa061
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</ng-container>

<!-- Payment costs -->
<ng-container *ngIf="totals.paymentCostsTotal">
<ng-container *ngIf="hasPaymentCostsTotal">
<dt class="col-6">{{ 'checkout.cart.payment_cost.label' | translate }}</dt>
<dd class="col-6">{{ totals.paymentCostsTotal | ishPrice }}</dd>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}));
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 67fa061

Please sign in to comment.