describe(`valid, without parameters`, () => { let result; const pq = new pgp.ParameterizedQuery(`select 1 as value`); beforeEach(done => { db.one(pq) .then(data => { result = data; }) .finally(done); }); it(`must return the right value`, () => { expect(result && result.value === 1).toBeTruthy(); }); });
describe(`without any options`, () => { let result; beforeEach(done => { const db1 = header({noWarnings: true, promiseLib: promise}).db; db1.query(`select * from users`) .then(data => { result = data; }) .finally(done); }); it(`must be able to execute queries`, () => { expect(result instanceof Array).toBe(true); }); });
it('Should succeed with right credentials', done => { mockLdapServer(port, 'uid=testuser, o=example').then(server => { const options = { suffix: 'o=example', url: `ldap://localhost:${port}`, dn: 'uid={{id}}, o=example', }; ldap .validateAuthData({ id: 'testuser', password: 'secret' }, options) .then(done) .catch(done.fail) .finally(() => server.close()); }); });
describe(`single-row function`, () => { let result; beforeEach(done => { db.func(`findUser`, 1, pgp.queryResult.one) .then(data => { result = data; }) .finally(done); }); it(`must return one object`, () => { expect(typeof result).toBe(`object`); expect(`id` in result && `login` in result && `active` in result).toBe(true); }); });