How to use the @hapi/code.expect function in @hapi/code

To help you get started, we’ve selected a few @hapi/code 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 jedireza / frame / test / server / models / user.js View on Github external
lab.test('it hydrates roles and caches the results for subsequent access', async () => {

        const user = await User.findByUsername('ren');

        await user.hydrateRoles();

        Code.expect(user._roles).to.be.an.object();
        Code.expect(Object.keys(user._roles)).to.have.length(1);
        Code.expect(user._roles.admin).to.be.an.instanceOf(Admin);

        const roles = await user.hydrateRoles();

        Code.expect(user._roles).to.equal(roles);
    });
});
github jedireza / frame / test / server / models / account.js View on Github external
lab.test('it parses names into name fields', () => {

        const justFirst = Account.nameAdapter('Steve');

        Code.expect(justFirst).to.be.an.object();
        Code.expect(justFirst.first).to.equal('Steve');
        Code.expect(justFirst.middle).to.equal('');
        Code.expect(justFirst.last).to.equal('');

        const firstAndLast = Account.nameAdapter('Ren Höek');

        Code.expect(firstAndLast).to.be.an.object();
        Code.expect(firstAndLast.first).to.equal('Ren');
        Code.expect(firstAndLast.middle).to.equal('');
        Code.expect(firstAndLast.last).to.equal('Höek');

        const withMiddle = Account.nameAdapter('Stimpson J Cat');

        Code.expect(withMiddle).to.be.an.object();
        Code.expect(withMiddle.first).to.equal('Stimpson');
        Code.expect(withMiddle.middle).to.equal('J');
        Code.expect(withMiddle.last).to.equal('Cat');
    });
github futurestudio / hapi-geo-locate / test / plugin-registration-without-config.js View on Github external
handler: request => request.location || 'no-location',
      config: {
        plugins: { 'hapi-geo-locate': { enabled: false } }
      }
    }

    server.route(routeOptions)

    const request = {
      url: routeOptions.path,
      method: routeOptions.method
    }

    const response = await server.inject(request)
    Code.expect(response.statusCode).to.equal(200)
    Code.expect(response.result).to.equal('no-location')
  })
})
github xogroup / bunnybus / test / integration.js View on Github external
[publishOptions.routeKey]: async (
                        consumedMessage,
                        meta,
                        ack
                    ) => {
                        expect(consumedMessage).to.equal(messageString);
                        expect(meta).to.not.be.a.function();
                        expect(meta.headers).to.exist();
                        await ack();
                        resolve();
                    }
                };
github futurestudio / hapi-geo-locate / test / plugin-registration-disabled-by-default.js View on Github external
handler: request => request.location,
      config: {
        plugins: { 'hapi-geo-locate': { enabled: true } }
      }
    }

    server.route(routeOptions)

    const request = {
      url: routeOptions.path,
      method: routeOptions.method
    }

    const response = await server.inject(request)
    Code.expect(response.statusCode).to.equal(200)
    Code.expect(Object.keys(response.result)).to.contain(['ip'])
  })
})
github jedireza / frame / test / server / models / admin.js View on Github external
const documentB = new Admin({
            name: Admin.nameAdapter('Ren B Höek'),
            groups: {
                sales: 'Sales',
                support: 'Support'
            }
        });

        const testB1 = await documentB.hasPermissionTo('SPACE_MADNESS');

        Code.expect(testB1).to.equal(true);

        const testB2 = await documentB.hasPermissionTo('UNTAMED_WORLD');

        Code.expect(testB2).to.equal(false);
    });
github metoikos / hapi-moon / test / all-routes.js View on Github external
expect(res.result.status).to.equal(true);
        expect(res.result.result.email).to.equal('sample2@test.com');
        const header = res.headers['set-cookie'];

        const yarCookie = header[0].match(/hapi-moon-auth=([^\x00-\x20\"\,\;\\\x7F]*)/);

        const res2 = await server.inject({
            url: '/user',
            method: 'get',
            headers: {
                cookie: `crumb=${cookie[1]};hapi-moon-auth=${yarCookie[1]}`,
                'x-csrf-token': cookie[1]
            }
        });

        expect(res2.statusCode).to.equal(200);
        expect(res2.result.email).to.equal('sample2@test.com');
    });
github beyonk-adventures / sapper-httpclient / lib / api / api.spec.js View on Github external
it('has cleared endpoint', () => {
        expect(api.config.endpoint).to.equal(null)
      })
github beyonk-adventures / sapper-httpclient / lib / api / api.spec.js View on Github external
it('calls url with delete method', async () => {
      clientStub.resolves({
        ok: true
      })
      await api.transport(clientStub).endpoint('some/url').del()
      expect(clientStub.firstCall.args[1].method).equals('delete')
    })
  })
github creditkarma / thrift-server / packages / thrift-integration / src / express / index.spec.ts View on Github external
return client.add(5, 7).then((response: number) => {
            expect(response).to.equal(12)
        })
    })

@hapi/code

assertion library

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular @hapi/code functions