From c5c009fadd6fe202f768b3f8e61ebc82d65a77df Mon Sep 17 00:00:00 2001 From: LongYinan Date: Tue, 28 May 2024 12:50:44 +0800 Subject: [PATCH] test(integrate-module): add compiled .js file spec --- packages/integrate-module/src/compiled.d.ts | 3 +++ packages/integrate-module/src/compiled.js | 5 +++++ packages/integrate-module/src/index.ts | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 packages/integrate-module/src/compiled.d.ts create mode 100644 packages/integrate-module/src/compiled.js diff --git a/packages/integrate-module/src/compiled.d.ts b/packages/integrate-module/src/compiled.d.ts new file mode 100644 index 000000000..d9913f520 --- /dev/null +++ b/packages/integrate-module/src/compiled.d.ts @@ -0,0 +1,3 @@ +export declare class CompiledClass { + name: string +} diff --git a/packages/integrate-module/src/compiled.js b/packages/integrate-module/src/compiled.js new file mode 100644 index 000000000..3caad40f7 --- /dev/null +++ b/packages/integrate-module/src/compiled.js @@ -0,0 +1,5 @@ +export class CompiledClass { + constructor() { + this.name = 'CompiledClass' + } +} diff --git a/packages/integrate-module/src/index.ts b/packages/integrate-module/src/index.ts index e21665746..1df3f6f77 100644 --- a/packages/integrate-module/src/index.ts +++ b/packages/integrate-module/src/index.ts @@ -2,9 +2,9 @@ import assert from 'node:assert' import test from 'node:test' +import { bar as subBar } from '@subdirectory/bar.mjs' import { supportedExtensions } from 'file-type' -import { bar as subBar } from '@subdirectory/bar.mjs' import { CompiledClass } from './compiled.js' import { foo } from './foo.mjs' import { bar } from './subdirectory/bar.mjs' @@ -30,3 +30,8 @@ await test('resolve nested entry point', () => { await test('resolve paths', () => { assert.equal(subBar(), 'bar') }) + +await test('compiled js file with .d.ts', () => { + const instance = new CompiledClass() + assert.equal(instance.name, 'CompiledClass') +})