From 8d60c2dfb87eb1cf6f47b7664062d83f99ced542 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 30 Apr 2024 12:50:57 -0700 Subject: [PATCH] added bosschaert demo --- tests/local/bossch.fnimported.js | 1 + tests/local/bossch.fnimporter.js | 5 +++++ tests/tests-node/esmock.node.bossch.test.js | 13 +++++++++++++ tests/tests-node/package.json | 2 +- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/local/bossch.fnimported.js create mode 100644 tests/local/bossch.fnimporter.js create mode 100644 tests/tests-node/esmock.node.bossch.test.js diff --git a/tests/local/bossch.fnimported.js b/tests/local/bossch.fnimported.js new file mode 100644 index 00000000..e743e840 --- /dev/null +++ b/tests/local/bossch.fnimported.js @@ -0,0 +1 @@ +export const fnimported = () => 'un-mocked' diff --git a/tests/local/bossch.fnimporter.js b/tests/local/bossch.fnimporter.js new file mode 100644 index 00000000..2c6861ef --- /dev/null +++ b/tests/local/bossch.fnimporter.js @@ -0,0 +1,5 @@ +import { fnimported } from './bossch.fnimported.js' + +export const fncaller = () => { + return fnimported() +} diff --git a/tests/tests-node/esmock.node.bossch.test.js b/tests/tests-node/esmock.node.bossch.test.js new file mode 100644 index 00000000..6a613d5d --- /dev/null +++ b/tests/tests-node/esmock.node.bossch.test.js @@ -0,0 +1,13 @@ +import test from 'node:test' +import assert from 'assert' +import esmock from 'esmock' + +test('should mock importedfn', async () => { + const { fncaller } = await esmock('../local/bossch.fnimporter.js', { + '../local/bossch.fnimported.js': { + fnimported: () => 'mocky' + } + }) + + assert.equal('mocky', fncaller()) +}) diff --git a/tests/tests-node/package.json b/tests/tests-node/package.json index 5427e7cd..01e4da4b 100644 --- a/tests/tests-node/package.json +++ b/tests/tests-node/package.json @@ -3,7 +3,7 @@ "description": "esmock unit tests, node native runner", "repository": { "type": "git", - "url": "https://github.com/iambumblehead/esmock.git" + "url": "gi+https://github.com/iambumblehead/esmock.git" }, "dependencies": { "esmock": "file:..",