How to use the @hapi/hoek.ignore function in @hapi/hoek

To help you get started, we’ve selected a few @hapi/hoek 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 / nes / test / socket.js View on Github external
it('errors on invalid message', async () => {

            const server = Hapi.server();
            await server.register({ plugin: Nes, options: { auth: false } });

            const log = server.events.once('log');

            await server.start();
            const client = new Nes.Client('http://localhost:' + server.info.port);
            client.onError = Hoek.ignore;
            await client.connect();

            const a = { id: 1, type: 'other' };
            a.c = a;                    // Circular reference

            server.plugins.nes._listener._sockets._forEach((socket) => {

                socket._send(a, null, Hoek.ignore);
            });

            const [event] = await log;
            expect(event.data).to.equal('other');
            client.disconnect();
            await server.stop();
        });
github hapijs / hapi / test / core.js View on Github external
it('fails to start server when registration incomplete', async () => {

            const plugin = {
                name: 'plugin',
                register: Hoek.ignore
            };

            const server = Hapi.server();
            server.register(plugin);
            await expect(server.start()).to.reject('Cannot start server before plugins finished registration');
        });
github hapipal / toys / test / index.js View on Github external
it('is a hapi plugin that does nothing and can be registered multiple times.', async () => {

            const server = Hapi.server();

            expect(Toys.noop.register).to.shallow.equal(Hoek.ignore);

            await server.register(Toys.noop);

            expect(server.registrations).to.only.contain('toys-noop');

            await server.register(Toys.noop);

            expect(server.registrations).to.only.contain('toys-noop');
        });
github hapijs / hapi / test / methods.js View on Github external
it('throws when registering a method with nested name twice', () => {

        const server = Hapi.server();
        server.method('tools.add', Hoek.ignore);
        expect(() => {

            server.method('tools.add', Hoek.ignore);
        }).to.throw('Server method function name already exists: tools.add');
    });
github hapijs / podium / test / index.js View on Github external
it('errors on unknown channel', async () => {

            const emitter = new Podium({ name: 'test', channels: ['a', 'b'] });
            emitter.on('test', Hoek.ignore);

            await expect(emitter.emit('test')).to.not.reject();
            await expect(emitter.emit({ name: 'test', channel: 'a' })).to.not.reject();
            await expect(emitter.emit({ name: 'test', channel: 'c' })).to.reject('Unknown c channel');
        });
github hapijs / nes / test / auth.js View on Github external
const server = Hapi.server();

            server.auth.scheme('custom', internals.implementation);
            server.auth.strategy('default', 'custom');
            server.auth.default('default');

            await server.register({ plugin: Nes, options: { auth: { type: 'direct', password } } });

            server.subscription('/', { auth: { entity: 'app' } });

            await server.start();
            const client = new Nes.Client('http://localhost:' + server.info.port);
            await client.connect({ auth: { headers: { authorization: 'Custom john' } } });

            await expect(client.subscribe('/', Hoek.ignore)).to.reject('User credentials cannot be used on an application subscription');
            expect(client.subscriptions()).to.equal([]);

            client.disconnect();
            await server.stop();
        });
github hapijs / nes / test / client.js View on Github external
const onSubscribe = (socket, path, params) => {

                const error = Boom.badRequest();
                delete error.output.payload.message;
                throw error;
            };

            await server.register({ plugin: Nes, options: { auth: false } });

            server.subscription('/', { onSubscribe });

            await server.start();
            const client = new Nes.Client('http://localhost:' + server.info.port);
            await client.connect();

            await expect(client.subscribe('/', Hoek.ignore)).to.reject('Bad Request');
            client.disconnect();
            await server.stop();
        });
    });
github hapijs / hapi / test / methods.js View on Github external
expect(() => {

            server.method('tools.add', Hoek.ignore);
        }).to.throw('Server method function name already exists: tools.add');
    });
github hapijs / hapi / test / payload.js View on Github external
const log = server.events.once('log');

        await server.start();

        const options = {
            hostname: 'localhost',
            port: server.info.port,
            path: '/',
            method: 'POST',
            headers: {
                'Content-Length': '10'
            }
        };

        const req = Http.request(options, (res) => { });
        req.on('error', Hoek.ignore);
        req.write('Hello\n');
        setTimeout(() => req.abort(), 50);

        const [event] = await log;
        expect(event.error.message).to.equal('Parse Error');
        await server.stop({ timeout: 10 });
    });
github hapipal / toys / lib / index.js View on Github external
static get noop() {

        return {
            name: 'toys-noop',
            multiple: true,
            register: Hoek.ignore
        };
    }