| 219 | }) |
| 220 | |
| 221 | function request () { |
| 222 | return new Promise((resolve, reject) => { |
| 223 | client.request({ |
| 224 | method: 'GET', |
| 225 | path: '/' |
| 226 | }, (err, { statusCode, body } = {}) => { |
| 227 | if (err) { |
| 228 | reject(err) |
| 229 | return |
| 230 | } |
| 231 | |
| 232 | const bufs = [] |
| 233 | |
| 234 | body.on('data', buf => { |
| 235 | bufs.push(buf) |
| 236 | }) |
| 237 | body.on('end', () => { |
| 238 | resolve({ |
| 239 | statusCode, |
| 240 | body: Buffer.concat(bufs) |
| 241 | }) |
| 242 | }) |
| 243 | body.on('error', reject) |
| 244 | }) |
| 245 | }) |
| 246 | } |
| 247 | |
| 248 | const smallResponse = await request() |
| 249 | t.strictEqual(smallResponse.statusCode, 200) |