diff --git a/.changeset/cool-rice-hunt.md b/.changeset/cool-rice-hunt.md new file mode 100644 index 0000000..86f62c2 --- /dev/null +++ b/.changeset/cool-rice-hunt.md @@ -0,0 +1,5 @@ +--- +"@hyperse/install-local": patch +--- + +fix test cases diff --git a/tests/core/cli.spec.ts b/tests/core/cli.spec.ts index 2c195e6..0610ee8 100644 --- a/tests/core/cli.spec.ts +++ b/tests/core/cli.spec.ts @@ -9,14 +9,13 @@ describe('cli', () => { dependencies: string[]; save: boolean; targetSiblings: boolean; - validate: Mock>; + validate: Mock<() => Promise>; }; let currentDirectoryInstallStub: MockInstance< - [optionsModule.Options], - Promise + (option: optionsModule.Options) => Promise >; - let siblingInstallStub: MockInstance<[], Promise>; + let siblingInstallStub: MockInstance<() => Promise>; beforeEach(() => { optionsMock = { diff --git a/tests/core/currentDirectoryInstall.spec.ts b/tests/core/currentDirectoryInstall.spec.ts index 8ba7bd7..e7fff6c 100644 --- a/tests/core/currentDirectoryInstall.spec.ts +++ b/tests/core/currentDirectoryInstall.spec.ts @@ -1,22 +1,22 @@ -import type { WriteStream } from 'tty'; import { Mock } from 'vitest'; import { MockInstance } from 'vitest'; import { currentDirectoryInstall } from '../../src/currentDirectoryInstall.js'; import * as helpers from '../../src/helpers.js'; -import { InstallTarget, Options, PackageJson } from '../../src/index.js'; +import { InstallTarget, PackageJson, saveIfNeeded } from '../../src/index.js'; import * as localInstallerModule from '../../src/LocalInstaller.js'; import * as progressModule from '../../src/progress.js'; import * as saveModule from '../../src/save.js'; import { options, packageJson } from '../helpers/producers.js'; describe('currentDirectoryInstall', () => { - let localInstallerStub: { install: Mock; on: Mock }; - let saveIfNeededStub: MockInstance<[InstallTarget[], Options], Promise>; - let readPackageJsonStub: MockInstance<[string], Promise>; - let progressStub: MockInstance< - [localInstallerModule.LocalInstaller, WriteStream?], - void - >; + let localInstallerStub: { + install: Mock<() => Promise>; + on: Mock; + }; + + let saveIfNeededStub: MockInstance; + let readPackageJsonStub: MockInstance<(from: string) => Promise>; + let progressStub: MockInstance; beforeEach(() => { localInstallerStub = { install: vi.fn(), on: vi.fn() }; // LocalInstaller is a class, so we need to mock the constructor, use `MockReturnValue` to mock the return value diff --git a/tests/core/helpers.spec.ts b/tests/core/helpers.spec.ts index ff63314..41dc527 100644 --- a/tests/core/helpers.spec.ts +++ b/tests/core/helpers.spec.ts @@ -4,7 +4,7 @@ import { MockInstance } from 'vitest'; import { readPackageJson } from '../../src/helpers.js'; describe('Helpers', () => { - let readFileStub: MockInstance>; + let readFileStub: MockInstance; beforeEach(() => { readFileStub = vi.spyOn(fs, 'readFile');