How to use @hapi/teamwork - 3 common examples

To help you get started, we’ve selected a few @hapi/teamwork examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / pez / test / index.js View on Github external
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;
    });
github hapijs / podium / test / index.js View on Github external
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;
        });
github hapijs / nigel / test / index.js View on Github external
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();
            });

@hapi/teamwork

Wait for multiple callback

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis

Popular @hapi/teamwork functions