(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>;
} = {})
| 37 | } |
| 38 | |
| 39 | function 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 | |
| 75 | describe('handleUpgrade', () => { |
| 76 | it('prompts before installing the latest version when the install source supports it', async () => { |
no test coverage detected