( path: string, log?: (label: string, value?: unknown) => void, )
| 57 | } |
| 58 | |
| 59 | async function getEnvelope<T>( |
| 60 | path: string, |
| 61 | log?: (label: string, value?: unknown) => void, |
| 62 | ): Promise<T> { |
| 63 | const res = await fetchWithReport(`${BASE_URL}${API_PREFIX}${path}`, { |
| 64 | headers: { accept: 'application/json' }, |
| 65 | }); |
| 66 | const body = (await res.json()) as Envelope<T>; |
| 67 | log?.('http envelope', { |
| 68 | method: 'GET', |
| 69 | path: `${API_PREFIX}${path}`, |
| 70 | status: res.status, |
| 71 | body, |
| 72 | }); |
| 73 | expect(typeof body.code, `${path} missing envelope.code`).toBe('number'); |
| 74 | expect(body.code, `${path} returned code=${body.code} msg=${body.msg ?? ''}`).toBe(0); |
| 75 | return body.data; |
| 76 | } |
| 77 | |
| 78 | interface HelloResult { |
| 79 | ws: WsClient; |
nothing calls this directly
no test coverage detected