@labdigital/commercetools-mock 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1291,12 +1291,11 @@ var CartRepository = class extends AbstractResourceRepository {
1291
1291
  (x) => x.productId === product?.id && x.variant.id === variant?.id
1292
1292
  );
1293
1293
  if (alreadyAdded) {
1294
- resource.lineItems.map((x) => {
1294
+ resource.lineItems.forEach((x) => {
1295
1295
  if (x.productId === product?.id && x.variant.id === variant?.id) {
1296
1296
  x.quantity += quantity;
1297
1297
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
1298
1298
  }
1299
- return x;
1300
1299
  });
1301
1300
  } else {
1302
1301
  if (!variant.prices?.length) {
@@ -1365,18 +1364,16 @@ var CartRepository = class extends AbstractResourceRepository {
1365
1364
  message: `Either lineItemid or lineItemKey needs to be provided.`
1366
1365
  });
1367
1366
  }
1368
- const shouldDelete = !quantity || quantity >= lineItem.quantity;
1369
- if (shouldDelete) {
1367
+ if (quantity === 0) {
1370
1368
  resource.lineItems = resource.lineItems.filter(
1371
1369
  (x) => x.id !== lineItemId
1372
1370
  );
1373
1371
  } else {
1374
- resource.lineItems.map((x) => {
1372
+ resource.lineItems.forEach((x) => {
1375
1373
  if (x.id === lineItemId && quantity) {
1376
- x.quantity -= quantity;
1374
+ x.quantity = quantity;
1377
1375
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
1378
1376
  }
1379
- return x;
1380
1377
  });
1381
1378
  }
1382
1379
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
@@ -1395,12 +1392,11 @@ var CartRepository = class extends AbstractResourceRepository {
1395
1392
  (x) => x.id !== lineItemId
1396
1393
  );
1397
1394
  } else {
1398
- resource.lineItems.map((x) => {
1395
+ resource.lineItems.forEach((x) => {
1399
1396
  if (x.id === lineItemId && quantity) {
1400
1397
  x.quantity -= quantity;
1401
1398
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
1402
1399
  }
1403
- return x;
1404
1400
  });
1405
1401
  }
1406
1402
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);