Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('returns a normal response when JSONP requested but stream returned', async () => {
const server = Hapi.server();
const stream = Wreck.toReadableStream('test');
stream.size = 4; // Non function for coverage
server.route({ method: 'GET', path: '/', options: { jsonp: 'callback', handler: () => stream } });
const res = await server.inject('/?callback=me');
expect(res.payload).to.equal('test');
});
});
it('returns a subset of a stream', async () => {
const random = Buffer.alloc(5000);
const source = Wreck.toReadableStream(random);
const range = Ammo.header('bytes=1000-4000', 5000);
const stream = new Ammo.Clip(range[0]);
const buffer = await Wreck.read(source.pipe(stream));
expect(buffer.toString()).to.equal(random.slice(1000, 4001).toString());
});