How to use the @hapi/lab.types function in @hapi/lab

To help you get started, we’ve selected a few @hapi/lab 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 / topo / test / index.ts View on Github external
import * as Topo from '..';
import * as Lab from '@hapi/lab';


const { expect } = Lab.types;


// new Topo.Sorter()

const morning = new Topo.Sorter();
morning.add('Nap', { after: ['breakfast', 'prep'] })
morning.add(['Make toast', 'Pour juice'], { before: 'breakfast', group: 'prep' });
morning.add('Eat breakfast', { group: 'breakfast' });

const afternoon = new Topo.Sorter();
afternoon.add('Eat lunch', { after: ['afternoon', 'prep'], sort: 2 });

expect.type(new Topo.Sorter());


// sorter.add()
github hapijs / address / test / index.ts View on Github external
import * as Address from '..';
import * as Lab from '@hapi/lab';


const { expect } = Lab.types;


// errors

expect.type(Address.errors.FORBIDDEN_UNICODE);


// domain.analyze()

Address.domain.analyze('example.com');
Address.domain.analyze('example.com', { minDomainSegments: 3, allowUnicode: false });
Address.domain.analyze('example.com', { tlds: false });
Address.domain.analyze('example.com', { tlds: true });
Address.domain.analyze('example.com', { tlds: { allow: new Set('x') } });
Address.domain.analyze('example.com', { tlds: { allow: new Set('x') } });
Address.domain.analyze('example.com', { tlds: { allow: true } });
github hapijs / boom / test / index.ts View on Github external
import * as Boom from '..';
import * as Lab from '@hapi/lab';

const { expect } = Lab.types;


class X {

    x: number;

    constructor(value: number) {

        this.x = value;
    }
};

const decorate = new X(1);


// new Boom.Boom()
github hapijs / teamwork / test / index.ts View on Github external
import * as Lab from '@hapi/lab';
import * as Teamwork from '..';


const { expect } = Lab.types;


// Constructor tests

expect.type(new Teamwork.Team());
expect.type(new Teamwork.Team({ meetings: 2 }));
expect.error(new Teamwork.Team({ foo: true }));
expect.error(new Teamwork.Team({ meetings: 'foo' }));
expect.type>(new Teamwork.Team().work);


// Attend tests

expect.type(new Teamwork.Team().attend());
expect.type(new Teamwork.Team().attend(new Error()));
expect.type(new Teamwork.Team().attend('foo'));
github hapijs / wreck / test / index.ts View on Github external
import * as Http from 'http';
import * as Net from 'net';

import * as Code from '@hapi/code';
import * as Lab from '@hapi/lab';
import * as Wreck from '..';


const { expect } = Lab.types;


// Provision server

const server = Http.createServer((req, res) => {

    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Some payload');
});

await new Promise((resolve) => server.listen(0, resolve));
const address = server.address() as Net.AddressInfo;
const url = `http://localhost:${address.port}`;


// request()
github hapijs / hoek / test / index.ts View on Github external
import * as Hoek from '..';
import * as Lab from '@hapi/lab';


const { expect } = Lab.types;


interface Foo {
    a?: number;
    b?: string;
};

interface Bar {
    b?: string;
    c?: boolean;
};


// deepEqual()

Hoek.deepEqual('some', 'some');
github hapijs / cryptiles / test / index.ts View on Github external
import * as Cryptiles from '..';
import * as Lab from '@hapi/lab';


const { expect } = Lab.types;


// randomString()

Cryptiles.randomString(256);
Cryptiles.randomString(5 * 5);

expect.type(Cryptiles.randomString(128))

expect.error(Cryptiles.randomString('some'));
expect.error(Cryptiles.randomString(true));
expect.error(Cryptiles.randomString({ foo: true }));
expect.error(Cryptiles.randomString(128, 256));


// randomDigits()
github hapijs / iron / test / index.ts View on Github external
import * as Iron from '..';
import * as Lab from '@hapi/lab';

const Cryptiles = require('@hapi/cryptiles');


const { expect } = Lab.types;


const password = 'some_not_random_password_that_is_also_long_enough';

const buffer = Cryptiles.randomBits(256);

const defaults = {
    encryption: {
        saltBits: 256,
        algorithm: 'aes-256-cbc',
        iterations: 1,
        minPasswordlength: 32
    },

    integrity: {
        saltBits: 256,

@hapi/lab

Test utility

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis

Popular @hapi/lab functions