Skip to content

Commit

Permalink
fix: review comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Oct 8, 2024
1 parent e6d4113 commit 0ed2ffc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/rakuten/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const calculateProductAmount = (product) => {
if (!product?.amount && !product?.price) {
throw new InstrumentationError('Either amount or price is required for every product');
}
return Math.round(product.amount) * 100 || (product.quantity || 1) * 100 * product.price;
return Math.round(product.amount * 100 || (product.quantity || 1) * 100 * product.price);
};

/**
Expand Down
12 changes: 5 additions & 7 deletions src/cdk/v2/destinations/rakuten/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ describe('constructLineItems', () => {
});
});

// Generated by qodo Gen

describe('calculateProductAmount', () => {
// Calculates product amount correctly when amount is defined
it('should return the correct product amount when amount is defined', () => {
Expand Down Expand Up @@ -151,29 +149,29 @@ describe('calculateProductAmount', () => {
it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.5, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(600);
expect(result).toEqual(550);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.1, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(500);
expect(result).toEqual(510);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.19, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(500);
expect(result).toEqual(519);
});

it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.199, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(500);
expect(result).toEqual(520);
});
it('should handle cases where amount is a floating-point number', () => {
const product = { amount: 5.479, price: 10, quantity: 2 };
const result = calculateProductAmount(product);
expect(result).toEqual(500);
expect(result).toEqual(548);
});
});

0 comments on commit 0ed2ffc

Please sign in to comment.