Skip to content

Commit

Permalink
Fix/SC-25 currency send to api (#1831)
Browse files Browse the repository at this point in the history
* fix: currency sent to api

* fix: unit test

* fix: currency sent to api

* fix: unit test of currency shop

* fix: currency sent to api

* fix: currency sent to api
  • Loading branch information
ClaraLpresta authored Oct 10, 2024
1 parent 399286f commit f8f3b9e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
44 changes: 42 additions & 2 deletions _dev/apps/ui/src/providers/shipping-rate-provider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('Product Feed / Step 2 Option 1 / Estimate Shipping', () => {
minDeliveryTime: 5,
maxDeliveryTime: 7,
countries: [],
currency: 'EUR',
currency: '',
freeShippingOverAmount: {
shippingCost: 0,
orderPrice: 0,
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('Product Feed / Step 2 Option 1 / Estimate Shipping', () => {
minDeliveryTime: 5,
maxDeliveryTime: 7,
countries: [],
currency: 'EUR',
currency: '',
freeShippingOverAmount: {
shippingCost: 2.99,
orderPrice: 42.99,
Expand All @@ -222,6 +222,46 @@ describe('Product Feed / Step 2 Option 1 / Estimate Shipping', () => {
]);
});

it('should be the shop currency if offer is freeShipping', () => {
const validCarrierFromView: CustomCarrier[] = [
{
carrierName: 'DLH',
offer: OfferType.FREE_SHIPPING,
minDeliveryTime: 5,
maxDeliveryTime: 7,
countries: [],
currency: '',
freeShippingOverAmount: {
shippingCost: 0,
orderPrice: 0,
},
flatShippingRate: {
shippingCost: 0,
},
},
];
const currencyShop = 'EUR';
const transform = toApi(validCarrierFromView, currencyShop);

expect(transform).toEqual([
{
carrierName: 'DLH',
offer: OfferType.FREE_SHIPPING,
minDeliveryTime: 5,
maxDeliveryTime: 7,
countries: [],
currency: 'EUR',
freeShippingOverAmount: {
shippingCost: 0,
orderPrice: 0,
},
flatShippingRate: {
shippingCost: 0,
},
},
]);
});

it('should return an empty array if estimateCarriers is empty', () => {
const transform = toApi([], '');

Expand Down
2 changes: 1 addition & 1 deletion _dev/apps/ui/src/providers/shipping-rate-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function toApi(customerCarrier: CustomCarrier[], currencyShop): CustomCar
if (carrier.freeShippingOverAmount.shippingCost === null) {
carrier.freeShippingOverAmount.shippingCost = 0;
}
if (carrier.currency !== currencyShop) {
if (carrier.offer === OfferType.FREE_SHIPPING) {
carrier.currency = currencyShop;
}
});
Expand Down

0 comments on commit f8f3b9e

Please sign in to comment.