diff --git a/test/fixtures/requires-a-reexported-function.js b/test/fixtures/requires-a-reexported-function.js new file mode 100644 index 0000000..f7f4fae --- /dev/null +++ b/test/fixtures/requires-a-reexported-function.js @@ -0,0 +1,5 @@ +const aFunction = require('./requires-and-exports-a-function') + +module.exports = function () { + return 'loaded ' + aFunction() +} diff --git a/test/fixtures/requires-and-exports-a-function.js b/test/fixtures/requires-and-exports-a-function.js new file mode 100644 index 0000000..3f8d390 --- /dev/null +++ b/test/fixtures/requires-and-exports-a-function.js @@ -0,0 +1,3 @@ +const aFunction = require('./a-function') + +module.exports = () => aFunction(); diff --git a/test/lib/quibble.test.js b/test/lib/quibble.test.js index d9cdefe..5fd6483 100644 --- a/test/lib/quibble.test.js +++ b/test/lib/quibble.test.js @@ -120,6 +120,17 @@ module.exports = { const result = quibbledRequiresAFunction() assert.equal(result, 'loaded a fake function') + }, + 'transitively requiring a module and then quibbling it': function () { + require('../fixtures/requires-a-reexported-function'); + quibble('../fixtures/a-function', function () { return 'a very fake function' }) + const quibbledRequiresAFunction = require('../fixtures/requires-a-reexported-function') + + const result = quibbledRequiresAFunction() + + quibble.reset() + + assert.equal(result, 'loaded a very fake function') } }, 'requiring-a-node-module': function () {