Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('errors if the payload size exceeds the byte limit', async () => {
const payload =
'--AaB03x\r\n' +
'content-disposition: form-data; name="file"; filename="file1.txt"\r\n' +
'Content-Type: text/plain\r\n' +
'\r\n' +
'I am a plain text file\r\n' +
'--AaB03x--\r\n';
const req = new internals.Payload(payload, true);
req.headers = { 'content-type': 'multipart/form-data; boundary="AaB03x"' };
const dispenser = new Pez.Dispenser({ boundary: 'AaB03x', maxBytes: payload.length - 1 });
const team = new Teamwork.Team();
dispenser.once('error', (err) => {
expect(err).to.exist();
expect(err.message).to.equal('Maximum size exceeded');
expect(err.output.statusCode).to.equal(413);
team.attend();
});
req.pipe(dispenser);
await team.work;
});
it('combines multiple sources in constructor', async () => {
const source1 = new Podium('test');
const source2 = new Podium('test');
const emitter = new Podium([source1, source2]);
const team = new Teamwork.Team({ meetings: 2 });
emitter.on('test', (data) => {
expect(data).to.equal(1);
team.attend();
});
source1.emit('test', 1);
source2.emit('test', 1);
await team.work;
});
it('emits events in correct order when nesting streams', async () => {
const team = new Teamwork.Team();
const test = '1x2|3|4x|5|6|x7';
let result = '';
const x = new Nigel.Stream(Buffer.from('x'));
const l = new Nigel.Stream(Buffer.from('|'));
x.once('close', () => {
l.end();
});
l.once('close', () => {
expect(result).to.equal(test.replace(/\|/g, '[').replace(/x/g, '*'));
team.attend();
});