Skip to content

Commit

Permalink
test: fixed an issue with test timeout as stream wasn't ready
Browse files Browse the repository at this point in the history
  • Loading branch information
lamweili committed Oct 3, 2022
1 parent 9299fb9 commit c122c42
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions test/node/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ describe('req.query(Object)', () => {
});
});

it('query-string should be sent on pipe', function (done) {
this.timeout(15_000);
it('query-string should be sent on pipe', (done) => {
const request_ = request.put(`${base}/?name=tobi`);
const stream = fs.createReadStream('test/node/fixtures/user.json');

Expand All @@ -213,9 +212,16 @@ describe('req.query(Object)', () => {
done(err);
});

stream.on('error', function (err) {
stream.on('error', (err) => {
done(err);
});
stream.pipe(request_);

// wait until stream is valid before piping
stream.on('open', () => {
// wait until request_ is ready before piping
setTimeout(() => {
stream.pipe(request_);
}, 10);
});
});
});

0 comments on commit c122c42

Please sign in to comment.