mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
add typecheck script and fix TypeScript errors (#48)
This commit is contained in:
1 parent
e853660ad3
commit
ed4bc17987
14 files changed
+371
-137
No files matched your search
@@ -22,8 +22,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
{ email: 'verified@email.com', primary: true, verified: true }
|
||||
])
|
||||
}
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
@@ -43,8 +43,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
})
|
||||
}
|
||||
const emailsResponse = { ok: false }
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
@@ -65,8 +65,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
ok: true,
|
||||
json: vi.fn().mockResolvedValue([])
|
||||
}
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
@@ -89,8 +89,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
{ email: 'unverified@email.com', primary: false, verified: false }
|
||||
])
|
||||
}
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
@@ -100,7 +100,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
|
||||
it('should return null when user API fails', async () => {
|
||||
const userResponse = { ok: false }
|
||||
global.fetch = vi.fn().mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('invalid_token')
|
||||
|
||||
@@ -116,7 +117,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
id: null
|
||||
})
|
||||
}
|
||||
global.fetch = vi.fn().mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
|
||||
@@ -132,7 +134,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
id: 123456
|
||||
})
|
||||
}
|
||||
global.fetch = vi.fn().mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
|
||||
@@ -149,8 +152,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
})
|
||||
}
|
||||
const emailsResponse = { ok: false }
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
@@ -160,7 +163,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
})
|
||||
|
||||
it('should handle network errors gracefully', async () => {
|
||||
global.fetch = vi.fn().mockRejectedValue(new Error('Network error'))
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockRejectedValue(new Error('Network error'))
|
||||
|
||||
const result = await fetchGitHubUserInfo('test_token')
|
||||
|
||||
@@ -182,8 +186,8 @@ describe('fetchGitHubUserInfo', () => {
|
||||
{ email: 'verified@email.com', primary: true, verified: true }
|
||||
])
|
||||
}
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
await fetchGitHubUserInfo('test_token')
|
||||
@@ -250,7 +254,7 @@ describe('findGitHubCredential', () => {
|
||||
describe('resolveGitIdentity', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
global.fetch = vi.fn()
|
||||
global.fetch = vi.fn() as any;
|
||||
})
|
||||
|
||||
it('should return manual identity when both name and email provided', async () => {
|
||||
@@ -287,8 +291,8 @@ describe('resolveGitIdentity', () => {
|
||||
])
|
||||
}
|
||||
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await resolveGitIdentity(manual, credentials)
|
||||
@@ -320,8 +324,8 @@ describe('resolveGitIdentity', () => {
|
||||
])
|
||||
}
|
||||
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await resolveGitIdentity(manual, credentials)
|
||||
@@ -353,8 +357,8 @@ describe('resolveGitIdentity', () => {
|
||||
])
|
||||
}
|
||||
|
||||
global.fetch = vi.fn()
|
||||
.mockResolvedValueOnce(userResponse)
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce(userResponse)
|
||||
.mockResolvedValueOnce(emailsResponse)
|
||||
|
||||
const result = await resolveGitIdentity(manual, credentials)
|
||||
@@ -371,7 +375,8 @@ describe('resolveGitIdentity', () => {
|
||||
{ name: 'github', host: 'https://github.com/', token: 'invalid-token' },
|
||||
]
|
||||
|
||||
global.fetch = vi.fn().mockResolvedValueOnce({ ok: false })
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce({ ok: false })
|
||||
|
||||
const result = await resolveGitIdentity(manual, credentials)
|
||||
|
||||
@@ -397,7 +402,8 @@ describe('resolveGitIdentity', () => {
|
||||
{ name: 'github', host: 'https://github.com/', token: 'invalid-token' },
|
||||
]
|
||||
|
||||
global.fetch = vi.fn().mockResolvedValueOnce({ ok: false })
|
||||
global.fetch = vi.fn() as any;
|
||||
(global.fetch as any).mockResolvedValueOnce({ ok: false })
|
||||
|
||||
const result = await resolveGitIdentity(manual, credentials)
|
||||
|
||||
|
||||
Reference in new issue
Block a user