From ed4dcd5155ed03d904b36900c1ee813c3508c531 Mon Sep 17 00:00:00 2001 From: chris Date: Tue, 12 Sep 2023 19:57:59 -0700 Subject: [PATCH] added a local file test to workspaces-ts --- tests/tests-workspaces/workspaces-ts/ts-b/index.ts | 3 +++ tests/tests-workspaces/workspaces-ts/ts-b/local-file.ts | 1 + tests/tests-workspaces/workspaces-ts/ts-b/test.ts | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 100644 tests/tests-workspaces/workspaces-ts/ts-b/local-file.ts diff --git a/tests/tests-workspaces/workspaces-ts/ts-b/index.ts b/tests/tests-workspaces/workspaces-ts/ts-b/index.ts index 103d63b0..426e23a3 100644 --- a/tests/tests-workspaces/workspaces-ts/ts-b/index.ts +++ b/tests/tests-workspaces/workspaces-ts/ts-b/index.ts @@ -1,5 +1,8 @@ import {foo} from 'ts-a' +import localfile from './local-file.js' export default function test () { return foo() } + +export const localfilewrap = () => localfile() diff --git a/tests/tests-workspaces/workspaces-ts/ts-b/local-file.ts b/tests/tests-workspaces/workspaces-ts/ts-b/local-file.ts new file mode 100644 index 00000000..6fd75c5f --- /dev/null +++ b/tests/tests-workspaces/workspaces-ts/ts-b/local-file.ts @@ -0,0 +1 @@ +export default () => 'local-value' diff --git a/tests/tests-workspaces/workspaces-ts/ts-b/test.ts b/tests/tests-workspaces/workspaces-ts/ts-b/test.ts index f0d6d3f0..6eb6f968 100644 --- a/tests/tests-workspaces/workspaces-ts/ts-b/test.ts +++ b/tests/tests-workspaces/workspaces-ts/ts-b/test.ts @@ -9,3 +9,11 @@ test('works ootb', async () => { assert.equal(sut(), 'bar') }) + +test('also mocks local file', async () => { + const { localfilewrap } = await esmock('./index.js', { + './local-file.js': () => 'local-value-mocked' + }) + + assert.equal(localfilewrap(), 'local-value-mocked') +})