The test of sending of stream, is badly constructed #56
Open
Description
Hi, this test line does not make sense, really what you are doing, is to test the behavior of microjs against a stream of data, not microrouter, the correct test would be like this:
test('route which sends a Stream', async (t) => {
const readable = new Readable()
const { methods, handler } = createRouter()
const { post } = methods
readable._read = () => {}
readable.push('foo')
readable.push(null)
post('/stream', (req, res) => {
let data = ''
req.on('data', (chunk) => data += chunk)
req.on('end', () => send(res, 200, data))
})
const url = await server(handler)
// using node-fetch support ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream, etc
const response = await fetch(`${url}/stream`, {
method: 'POST'
, body: readable
})
t.is(await response.text(), 'foo')
})`
I realized this because I'm making my own routing system, based on yours.
Regards.
Metadata
Assignees
Labels
No labels