breaking: bring your own sinon instead of bundling, to resolve leaks when versions...
[squeep-test-helper] / lib / stub-database.js
index 92f3a84ef9910418da86e7ccc5b5377835effc93..7abfb396876addad4ce24bfddcdd113be6ea70d7 100644 (file)
@@ -1,10 +1,9 @@
 /* eslint-disable class-methods-use-this */
 'use strict';
 
-const sinon = require('sinon');
-
 class StubDatabase {
-  constructor() {
+  constructor(sinon) {
+    this._sinon = sinon;
     this._implementation.forEach((fn) => {
       if (!(fn in this)) {
         this[fn] = async () => undefined; // eslint-disable-line security/detect-object-injection
@@ -35,10 +34,10 @@ class StubDatabase {
 
   _reset() {
     this._spyFns.forEach((fn) => {
-      sinon.spy(this, fn);
+      this._sinon.spy(this, fn);
     });
     this._stubFns.forEach((fn) => {
-      sinon.stub(this, fn);
+      this._sinon.stub(this, fn);
     });
   }