({ path: reqPath = '/v1/messages', headers, body })
| 75 | srv.actualPort = port; |
| 76 | |
| 77 | const call = ({ path: reqPath = '/v1/messages', headers, body }) => new Promise((resolve, reject) => { |
| 78 | const req = http.request({ host: '127.0.0.1', port, path: reqPath, method: 'POST', |
| 79 | headers: { 'content-type': 'application/json', authorization: 'Bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'x-api-key': 'sk-client', ...headers } }, (res) => { |
| 80 | const chunks = []; |
| 81 | res.on('data', (d) => chunks.push(d)); |
| 82 | res.on('end', () => resolve({ status: res.statusCode, bytes: Buffer.concat(chunks) })); |
| 83 | }); |
| 84 | req.on('error', reject); |
| 85 | req.end(JSON.stringify(body)); |
| 86 | }); |
| 87 | |
| 88 | // Each test issues a non-stream + a stream call; the streamed row emits only once its SSE body is drained, |
| 89 | // so wait for the expected count (not just the first line) before asserting. |
no outgoing calls
no test coverage detected