@zimic/interceptor 0.17.0 → 0.17.1-canary.0

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/http.mjs CHANGED
@@ -142,11 +142,11 @@ var DisabledRequestSavingError = class extends TypeError {
142
142
  };
143
143
  var DisabledRequestSavingError_default = DisabledRequestSavingError;
144
144
 
145
- // ../zimic-utils/dist/chunk-PAWJFY3S.mjs
145
+ // ../zimic-utils/dist/chunk-6IEM75FG.mjs
146
146
  var __defProp2 = Object.defineProperty;
147
147
  var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
148
148
 
149
- // ../zimic-utils/dist/chunk-3O5CS47X.mjs
149
+ // ../zimic-utils/dist/chunk-INCJAGFR.mjs
150
150
  function isDefined(value) {
151
151
  return value !== void 0 && value !== null;
152
152
  }
@@ -431,7 +431,7 @@ __name(blobContains, "blobContains");
431
431
  __name2(blobContains, "blobContains");
432
432
  var blobContains_default = blobContains;
433
433
 
434
- // ../zimic-utils/dist/chunk-HVLEF6VF.mjs
434
+ // ../zimic-utils/dist/chunk-VXSYL3FX.mjs
435
435
  async function blobEquals(blob, otherBlob) {
436
436
  return blob.type === otherBlob.type && blob.size === otherBlob.size && await blob.text() === await otherBlob.text();
437
437
  }
@@ -439,12 +439,15 @@ __name(blobEquals, "blobEquals");
439
439
  __name2(blobEquals, "blobEquals");
440
440
  var blobEquals_default = blobEquals;
441
441
 
442
- // src/utils/json.ts
442
+ // ../zimic-utils/dist/chunk-C76RTUXI.mjs
443
443
  function isPrimitiveJSONValue(value) {
444
444
  return typeof value !== "object" || value === null;
445
445
  }
446
446
  __name(isPrimitiveJSONValue, "isPrimitiveJSONValue");
447
- function jsonEquals(value, otherValue) {
447
+ __name2(isPrimitiveJSONValue, "isPrimitiveJSONValue");
448
+
449
+ // ../zimic-utils/dist/data/jsonContains.mjs
450
+ function jsonContains(value, otherValue) {
448
451
  if (isPrimitiveJSONValue(value)) {
449
452
  return value === otherValue;
450
453
  }
@@ -455,27 +458,40 @@ function jsonEquals(value, otherValue) {
455
458
  if (!Array.isArray(otherValue)) {
456
459
  return false;
457
460
  }
458
- if (value.length !== otherValue.length) {
461
+ if (value.length < otherValue.length) {
459
462
  return false;
460
463
  }
461
- return value.every((item, index) => jsonEquals(item, otherValue[index]));
464
+ let lastMatchedIndex = -1;
465
+ return otherValue.every((otherItem) => {
466
+ for (let index = lastMatchedIndex + 1; index < value.length; index++) {
467
+ if (jsonContains(value[index], otherItem)) {
468
+ lastMatchedIndex = index;
469
+ return true;
470
+ }
471
+ }
472
+ return false;
473
+ });
462
474
  }
463
475
  if (Array.isArray(otherValue)) {
464
476
  return false;
465
477
  }
466
478
  const valueKeys = Object.keys(value);
467
479
  const otherValueKeys = Object.keys(otherValue);
468
- if (valueKeys.length !== otherValueKeys.length) {
480
+ if (valueKeys.length < otherValueKeys.length) {
469
481
  return false;
470
482
  }
471
- return valueKeys.every((key) => {
483
+ return otherValueKeys.every((key) => {
472
484
  const subValue = value[key];
473
485
  const subOtherValue = otherValue[key];
474
- return jsonEquals(subValue, subOtherValue);
486
+ return jsonContains(subValue, subOtherValue);
475
487
  });
476
488
  }
477
- __name(jsonEquals, "jsonEquals");
478
- function jsonContains(value, otherValue) {
489
+ __name(jsonContains, "jsonContains");
490
+ __name2(jsonContains, "jsonContains");
491
+ var jsonContains_default = jsonContains;
492
+
493
+ // ../zimic-utils/dist/data/jsonEquals.mjs
494
+ function jsonEquals(value, otherValue) {
479
495
  if (isPrimitiveJSONValue(value)) {
480
496
  return value === otherValue;
481
497
  }
@@ -486,35 +502,28 @@ function jsonContains(value, otherValue) {
486
502
  if (!Array.isArray(otherValue)) {
487
503
  return false;
488
504
  }
489
- if (value.length < otherValue.length) {
505
+ if (value.length !== otherValue.length) {
490
506
  return false;
491
507
  }
492
- let lastMatchedIndex = -1;
493
- return otherValue.every((otherItem) => {
494
- for (let index = lastMatchedIndex + 1; index < value.length; index++) {
495
- if (jsonContains(value[index], otherItem)) {
496
- lastMatchedIndex = index;
497
- return true;
498
- }
499
- }
500
- return false;
501
- });
508
+ return value.every((item, index) => jsonEquals(item, otherValue[index]));
502
509
  }
503
510
  if (Array.isArray(otherValue)) {
504
511
  return false;
505
512
  }
506
513
  const valueKeys = Object.keys(value);
507
514
  const otherValueKeys = Object.keys(otherValue);
508
- if (valueKeys.length < otherValueKeys.length) {
515
+ if (valueKeys.length !== otherValueKeys.length) {
509
516
  return false;
510
517
  }
511
- return otherValueKeys.every((key) => {
518
+ return valueKeys.every((key) => {
512
519
  const subValue = value[key];
513
520
  const subOtherValue = otherValue[key];
514
- return jsonContains(subValue, subOtherValue);
521
+ return jsonEquals(subValue, subOtherValue);
515
522
  });
516
523
  }
517
- __name(jsonContains, "jsonContains");
524
+ __name(jsonEquals, "jsonEquals");
525
+ __name2(jsonEquals, "jsonEquals");
526
+ var jsonEquals_default = jsonEquals;
518
527
 
519
528
  // src/http/requestHandler/errors/NoResponseDefinitionError.ts
520
529
  var NoResponseDefinitionError = class extends TypeError {
@@ -737,7 +746,7 @@ var HttpRequestHandlerClient = class {
737
746
  diff: { expected: restrictionBody, received: body }
738
747
  };
739
748
  }
740
- const matchesRestriction = restriction.exact ? jsonEquals(request.body, restriction.body) : jsonContains(request.body, restriction.body);
749
+ const matchesRestriction = restriction.exact ? jsonEquals_default(request.body, restriction.body) : jsonContains_default(request.body, restriction.body);
741
750
  return matchesRestriction ? { value: true } : {
742
751
  value: false,
743
752
  diff: { expected: restrictionBody, received: body }
@@ -832,7 +841,7 @@ var LocalHttpRequestHandler = class {
832
841
  };
833
842
  var LocalHttpRequestHandler_default = LocalHttpRequestHandler;
834
843
 
835
- // ../zimic-utils/dist/chunk-RIVHLEFF.mjs
844
+ // ../zimic-utils/dist/chunk-PFX6YIKR.mjs
836
845
  var URL_PATH_PARAM_REGEX = /\/:([^/]+)/g;
837
846
  function createRegExpFromURL(url) {
838
847
  URL_PATH_PARAM_REGEX.lastIndex = 0;