MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / createDeps

Function createDeps

apps/kimi-code/test/cli/upgrade.test.ts:39–73  ·  view source on GitHub ↗
(overrides: {
  readonly latest?: string | null;
  readonly manifest?: UpdateCache['manifest'];
  readonly source?: InstallSource;
  readonly isInteractive?: boolean;
  readonly promptForInstallChoice?: () => Promise<InstallPromptChoiceValue>;
  readonly installUpdate?: (source: InstallSource, version: string, platform: NodeJS.Platform) => Promise<void>;
} = {})

Source from the content-addressed store, hash-verified

37}
38
39function createDeps(overrides: {
40 readonly latest?: string | null;
41 readonly manifest?: UpdateCache['manifest'];
42 readonly source?: InstallSource;
43 readonly isInteractive?: boolean;
44 readonly promptForInstallChoice?: () => Promise<InstallPromptChoiceValue>;
45 readonly installUpdate?: (source: InstallSource, version: string, platform: NodeJS.Platform) => Promise<void>;
46} = {}) {
47 const installUpdate =
48 overrides.installUpdate ??
49 vi.fn<(
50 source: InstallSource,
51 version: string,
52 platform: NodeJS.Platform,
53 ) => Promise<void>>().mockResolvedValue(undefined);
54
55 return {
56 refreshUpdateCache: vi
57 .fn()
58 .mockResolvedValue(cacheWith(overrides.latest ?? '0.5.0', overrides.manifest ?? null)),
59 detectInstallSource: vi.fn().mockResolvedValue(overrides.source ?? 'npm-global'),
60 promptForInstallChoice:
61 overrides.promptForInstallChoice ?? vi.fn().mockResolvedValue('install'),
62 installUpdate,
63 track: vi.fn(),
64 logger: {
65 info: vi.fn(),
66 warn: vi.fn(),
67 error: vi.fn(),
68 debug: vi.fn(),
69 },
70 platform: 'darwin' as NodeJS.Platform,
71 isInteractive: overrides.isInteractive ?? true,
72 };
73}
74
75describe('handleUpgrade', () => {
76 it('prompts before installing the latest version when the install source supports it', async () => {

Callers 1

upgrade.test.tsFile · 0.70

Calls 1

cacheWithFunction · 0.70

Tested by

no test coverage detected