@labdigital/commercetools-mock 1.3.0 → 1.3.1

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.
@@ -36379,15 +36379,15 @@ ${this.pendingMocks().join("\n")}`
36379
36379
  exports.EOF = token_1.EOF;
36380
36380
  var token_types_1 = require_token_types();
36381
36381
  exports.TokenTypes = token_types_1.default;
36382
- var Lexer = function() {
36383
- function Lexer2(source) {
36382
+ var Lexer3 = function() {
36383
+ function Lexer4(source) {
36384
36384
  if (source === void 0) {
36385
36385
  source = "";
36386
36386
  }
36387
36387
  this._state = new lexer_state_1.default(source);
36388
36388
  this._tokenTypes = new token_types_1.default();
36389
36389
  }
36390
- Object.defineProperty(Lexer2.prototype, "position", {
36390
+ Object.defineProperty(Lexer4.prototype, "position", {
36391
36391
  //
36392
36392
  // Getters/Setters
36393
36393
  //
@@ -36408,7 +36408,7 @@ ${this.pendingMocks().join("\n")}`
36408
36408
  enumerable: true,
36409
36409
  configurable: true
36410
36410
  });
36411
- Object.defineProperty(Lexer2.prototype, "source", {
36411
+ Object.defineProperty(Lexer4.prototype, "source", {
36412
36412
  /**
36413
36413
  * Gets the source the lexer is operating on
36414
36414
  * @return {string} Returns the source
@@ -36426,18 +36426,18 @@ ${this.pendingMocks().join("\n")}`
36426
36426
  enumerable: true,
36427
36427
  configurable: true
36428
36428
  });
36429
- Lexer2.prototype.attachTo = function(other) {
36429
+ Lexer4.prototype.attachTo = function(other) {
36430
36430
  this._state = other._state;
36431
36431
  };
36432
- Lexer2.prototype.disable = function(type) {
36432
+ Lexer4.prototype.disable = function(type) {
36433
36433
  this._tokenTypes.disable(type);
36434
36434
  return this;
36435
36435
  };
36436
- Lexer2.prototype.enable = function(type, enabled) {
36436
+ Lexer4.prototype.enable = function(type, enabled) {
36437
36437
  this._tokenTypes.enable(type, enabled);
36438
36438
  return this;
36439
36439
  };
36440
- Lexer2.prototype.expect = function(type) {
36440
+ Lexer4.prototype.expect = function(type) {
36441
36441
  var t = this.next();
36442
36442
  if (t.type != type) {
36443
36443
  var pos = t.strpos();
@@ -36445,10 +36445,10 @@ ${this.pendingMocks().join("\n")}`
36445
36445
  }
36446
36446
  return t;
36447
36447
  };
36448
- Lexer2.prototype.isEnabled = function(tokenType) {
36448
+ Lexer4.prototype.isEnabled = function(tokenType) {
36449
36449
  return this._tokenTypes.isEnabled(tokenType);
36450
36450
  };
36451
- Lexer2.prototype.next = function() {
36451
+ Lexer4.prototype.next = function() {
36452
36452
  try {
36453
36453
  var t = this.peek();
36454
36454
  this._state.position = t.end;
@@ -36458,7 +36458,7 @@ ${this.pendingMocks().join("\n")}`
36458
36458
  throw e;
36459
36459
  }
36460
36460
  };
36461
- Lexer2.prototype.peek = function(position) {
36461
+ Lexer4.prototype.peek = function(position) {
36462
36462
  var _this = this;
36463
36463
  if (position === void 0) {
36464
36464
  position = this._state.position;
@@ -36489,7 +36489,7 @@ ${this.pendingMocks().join("\n")}`
36489
36489
  e.end = position + unexpected.length;
36490
36490
  throw e;
36491
36491
  };
36492
- Lexer2.prototype.strpos = function(i) {
36492
+ Lexer4.prototype.strpos = function(i) {
36493
36493
  var lines = this._state.source.substring(0, i).split(/\r?\n/);
36494
36494
  if (!Array.isArray(lines))
36495
36495
  lines = [lines];
@@ -36497,7 +36497,7 @@ ${this.pendingMocks().join("\n")}`
36497
36497
  var column = lines[lines.length - 1].length + 1;
36498
36498
  return { line, column };
36499
36499
  };
36500
- Lexer2.prototype.toArray = function() {
36500
+ Lexer4.prototype.toArray = function() {
36501
36501
  var oldState = this._state.copy();
36502
36502
  this._state.position = 0;
36503
36503
  var tkns = [];
@@ -36507,20 +36507,20 @@ ${this.pendingMocks().join("\n")}`
36507
36507
  this._state = oldState;
36508
36508
  return tkns;
36509
36509
  };
36510
- Lexer2.prototype.token = function(type, pattern, skip) {
36510
+ Lexer4.prototype.token = function(type, pattern, skip) {
36511
36511
  this._tokenTypes.token(type, pattern, skip);
36512
36512
  return this;
36513
36513
  };
36514
- Lexer2.prototype.keyword = function(kwd) {
36514
+ Lexer4.prototype.keyword = function(kwd) {
36515
36515
  return this.token(kwd, new RegExp(kwd + "(?=\\W|$)"));
36516
36516
  };
36517
- Lexer2.prototype.operator = function(op) {
36517
+ Lexer4.prototype.operator = function(op) {
36518
36518
  var sOp = new String(op).valueOf();
36519
36519
  return this.token(op, sOp);
36520
36520
  };
36521
- return Lexer2;
36521
+ return Lexer4;
36522
36522
  }();
36523
- exports.default = Lexer;
36523
+ exports.default = Lexer3;
36524
36524
  }
36525
36525
  });
36526
36526
 
@@ -41575,12 +41575,11 @@ ${this.pendingMocks().join("\n")}`
41575
41575
  (x) => x.productId === product?.id && x.variant.id === variant?.id
41576
41576
  );
41577
41577
  if (alreadyAdded) {
41578
- resource.lineItems.map((x) => {
41578
+ resource.lineItems.forEach((x) => {
41579
41579
  if (x.productId === product?.id && x.variant.id === variant?.id) {
41580
41580
  x.quantity += quantity;
41581
41581
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
41582
41582
  }
41583
- return x;
41584
41583
  });
41585
41584
  } else {
41586
41585
  if (!variant.prices?.length) {
@@ -41649,18 +41648,16 @@ ${this.pendingMocks().join("\n")}`
41649
41648
  message: `Either lineItemid or lineItemKey needs to be provided.`
41650
41649
  });
41651
41650
  }
41652
- const shouldDelete = !quantity || quantity >= lineItem.quantity;
41653
- if (shouldDelete) {
41651
+ if (quantity === 0) {
41654
41652
  resource.lineItems = resource.lineItems.filter(
41655
41653
  (x) => x.id !== lineItemId
41656
41654
  );
41657
41655
  } else {
41658
- resource.lineItems.map((x) => {
41656
+ resource.lineItems.forEach((x) => {
41659
41657
  if (x.id === lineItemId && quantity) {
41660
- x.quantity -= quantity;
41658
+ x.quantity = quantity;
41661
41659
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
41662
41660
  }
41663
- return x;
41664
41661
  });
41665
41662
  }
41666
41663
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
@@ -41679,12 +41676,11 @@ ${this.pendingMocks().join("\n")}`
41679
41676
  (x) => x.id !== lineItemId
41680
41677
  );
41681
41678
  } else {
41682
- resource.lineItems.map((x) => {
41679
+ resource.lineItems.forEach((x) => {
41683
41680
  if (x.id === lineItemId && quantity) {
41684
41681
  x.quantity -= quantity;
41685
41682
  x.totalPrice.centAmount = calculateLineItemTotalPrice(x);
41686
41683
  }
41687
- return x;
41688
41684
  });
41689
41685
  }
41690
41686
  resource.totalPrice.centAmount = calculateCartTotalPrice(resource);