Skip to content

Commit

Permalink
re-add async iteration test
Browse files Browse the repository at this point in the history
  • Loading branch information
cjihrig committed Aug 25, 2020
1 parent ea52b07 commit 23ea0cb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,25 @@ describe('_read()', () => {
expect(res.payload).to.equal(body);
});

it('supports async iteration', async () => {

const dispatch = async function (req, res) {

let buffer = '';
for await (const chunk of req) {
buffer = buffer + chunk.toString();
}

res.writeHead(200, { 'Content-Length': 0 });
res.end(buffer);
req.destroy();
};

const body = 'something special just for you';
const res = await Shot.inject(dispatch, { method: 'get', url: '/', payload: body });
expect(res.payload).to.equal(body);
});

it('simulates split', async () => {

const dispatch = function (req, res) {
Expand Down

0 comments on commit 23ea0cb

Please sign in to comment.