Download desktop/src/api/openTargets.test.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 1.19 kB
-
https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.test.ts
- Command line
-
hf download hf://chenbhao/codev@e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.test.ts
-
curl -L -o openTargets.test.ts https://huggingface.co/chenbhao/codev/resolve/e40073cc959cd4729bf4009662bca374c5c4e266/desktop/src/api/openTargets.test.ts
1.19 kB
| import { afterEach, describe, expect, it, vi } from 'vitest' | |
| import { getDefaultBaseUrl, setBaseUrl } from './client' | |
| import { openTargetsApi } from './openTargets' | |
| describe('openTargetsApi', () => { | |
| afterEach(() => { | |
| setBaseUrl(getDefaultBaseUrl()) | |
| vi.restoreAllMocks() | |
| }) | |
| it('normalizes relative icon URLs to the configured desktop server URL', async () => { | |
| const fetchMock = vi.spyOn(globalThis, 'fetch') | |
| fetchMock.mockResolvedValueOnce(new Response(JSON.stringify({ | |
| platform: 'darwin', | |
| targets: [ | |
| { | |
| id: 'vscode', | |
| kind: 'ide', | |
| label: 'VS Code', | |
| icon: 'vscode', | |
| iconUrl: '/api/open-targets/icons/vscode', | |
| platform: 'darwin', | |
| }, | |
| ], | |
| primaryTargetId: 'vscode', | |
| cachedAt: 1, | |
| ttlMs: 30_000, | |
| }), { | |
| status: 200, | |
| headers: { 'Content-Type': 'application/json' }, | |
| })) | |
| setBaseUrl('http://127.0.0.1:49237') | |
| await expect(openTargetsApi.list()).resolves.toMatchObject({ | |
| targets: [ | |
| { | |
| id: 'vscode', | |
| iconUrl: 'http://127.0.0.1:49237/api/open-targets/icons/vscode', | |
| }, | |
| ], | |
| }) | |
| }) | |
| }) | |