summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/utils/updateCheck.test.ts
diff options
context:
space:
mode:
authorGal Zahavi <[email protected]>2025-07-28 17:56:52 -0700
committerGitHub <[email protected]>2025-07-29 00:56:52 +0000
commit871e0dfab811192f67cd80bc270580ad784ffdc8 (patch)
treebcb8de6af3a2e52a7d7597e5b28465c35b87f60a /packages/cli/src/ui/utils/updateCheck.test.ts
parent83c4dddb7ee7ba34d7dec09d00819972d2e1ff5f (diff)
feat: Add auto update functionality (#4686)
Diffstat (limited to 'packages/cli/src/ui/utils/updateCheck.test.ts')
-rw-r--r--packages/cli/src/ui/utils/updateCheck.test.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/cli/src/ui/utils/updateCheck.test.ts b/packages/cli/src/ui/utils/updateCheck.test.ts
index 975c320d..4985afe8 100644
--- a/packages/cli/src/ui/utils/updateCheck.test.ts
+++ b/packages/cli/src/ui/utils/updateCheck.test.ts
@@ -50,7 +50,9 @@ describe('checkForUpdates', () => {
name: 'test-package',
version: '1.0.0',
});
- updateNotifier.mockReturnValue({ update: null });
+ updateNotifier.mockReturnValue({
+ fetchInfo: vi.fn(async () => null),
+ });
const result = await checkForUpdates();
expect(result).toBeNull();
});
@@ -61,10 +63,12 @@ describe('checkForUpdates', () => {
version: '1.0.0',
});
updateNotifier.mockReturnValue({
- update: { current: '1.0.0', latest: '1.1.0' },
+ fetchInfo: vi.fn(async () => ({ current: '1.0.0', latest: '1.1.0' })),
});
+
const result = await checkForUpdates();
- expect(result).toContain('1.0.0 → 1.1.0');
+ expect(result?.message).toContain('1.0.0 → 1.1.0');
+ expect(result?.update).toEqual({ current: '1.0.0', latest: '1.1.0' });
});
it('should return null if the latest version is the same as the current version', async () => {
@@ -73,7 +77,7 @@ describe('checkForUpdates', () => {
version: '1.0.0',
});
updateNotifier.mockReturnValue({
- update: { current: '1.0.0', latest: '1.0.0' },
+ fetchInfo: vi.fn(async () => ({ current: '1.0.0', latest: '1.0.0' })),
});
const result = await checkForUpdates();
expect(result).toBeNull();
@@ -85,7 +89,7 @@ describe('checkForUpdates', () => {
version: '1.1.0',
});
updateNotifier.mockReturnValue({
- update: { current: '1.1.0', latest: '1.0.0' },
+ fetchInfo: vi.fn(async () => ({ current: '1.0.0', latest: '0.09' })),
});
const result = await checkForUpdates();
expect(result).toBeNull();