@noego/testing 0.7.3 → 0.7.4

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
@@ -330,6 +330,7 @@ function recordOutcome(call, outcome, threw) {
330
330
  else call.result = outcome;
331
331
  return outcome;
332
332
  }
333
+ var pristineMethods = /* @__PURE__ */ new WeakMap();
333
334
  function createMethodDecorator(registry) {
334
335
  const wrappers = /* @__PURE__ */ new WeakMap();
335
336
  return function decorate(instance, token2) {
@@ -351,8 +352,11 @@ function createMethodDecorator(registry) {
351
352
  }
352
353
  }
353
354
  if (Object.isExtensible(instance)) {
355
+ const pristine = pristineMethods.get(instance) ?? /* @__PURE__ */ new Map();
356
+ pristineMethods.set(instance, pristine);
354
357
  for (const [method, { entryKey, descriptor }] of effective) {
355
- const original = instance[method];
358
+ const original = pristine.get(method) ?? instance[method];
359
+ pristine.set(method, original);
356
360
  const wrapped = buildMethodWrapper(instance, method, descriptor, registry.state(entryKey, method), original);
357
361
  Object.defineProperty(instance, method, { value: wrapped, configurable: true, writable: true, enumerable: false });
358
362
  }