it("should return an error when pusage fails", (done) => { sandbox.stub(pusage, "stat").yields(new Error("bad error")); agent._getStats((err, metrics) => { tryCatch(done, () => { expect(err).to.exist; expect(metrics).to.be.undefined; expect(err.message).to.equal("bad error"); }); }); });
describe('API :: POST /api/users', () => { context('when sent data is ok', () => { it('creates and returns 201 and the new user', async () => { const { body } = await request() .post('/api/users') .send({ name: 'New User' }) .expect(201); expect(body.id).to.exist; expect(body.name).to.equal('New User'); expect(body).to.have.all.keys('id', 'name'); }); }); context('when name is missing', () => { it('does not create and returns 400 with the validation error', async () => { const { body } = await request() .post('/api/users') .expect(400); expect(body.type).to.equal('ValidationError'); expect(body.details).to.have.lengthOf(1); expect(body.details[0].message).to.equal('"name" is required'); }); }); });
const persistedUser = await repository.add(user); expect(persistedUser.id).to.exist; expect(persistedUser.name).to.equal('The User'); }).to.alter(() => repository.count(), { by: 1 });
it('should keep state until finished', () => { recorder.record(record(rootId, 1, new Annotation.ClientSend())); expect(pendingSpan(rootId)).to.exist; // eslint-disable-line no-unused-expressions recorder.record(record(rootId, 3, new Annotation.ClientRecv())); expect(pendingSpan(rootId)).to.not.exist; // eslint-disable-line no-unused-expressions popSpan(); // consume the span created above. });
it('creates a configReader', function () { var config = { } var configReader = ConfigReader.create(config) expect(configReader).to.exist })
it('does not create a prepared statement when the operation is executed once', () => { const expected = [{ _id: '1', name: 'quux' }, { _id: '2', name: 'bar' }, { _id: '3', name: 'baz' }, { _id: '4', name: 'qux' }]; const actual = []; return collection.modify('_id = :id') .bind('id', '1') .set('name', 'quux') .execute() .then(() => util.getPreparedStatement(session, 1)) .then(statement => expect(statement).to.not.exist) .then(() => collection.find().execute(doc => actual.push(doc))) .then(() => expect(actual).to.deep.equal(expected)); });
it('should insert a single document', async() => { const doc = await db.b.insert({ foo: 'bar' }); expect(doc.foo).to.equal('bar'); expect(doc._id).to.exist; });
describe('#getSpaceHomePage', function () { it('should get a space home page', function (done) { var confluence = new Confluence(config); confluence.getSpaceHomePage(space, function(err, data) { expect(err).to.be.null; expect(data).not.to.be.null; expect(data.id).to.exist; done(); }); }); });
it('mailservice', function () { expect(options.mailservice).to.exist; expect(options.mailservice.validate('Mailgun')).to.be.true; expect(options.mailservice.validate('CaspersFriendlyEmailService')).to.match(/Invalid mail service/); });
it('moves the cursor explicitely to the next result-set', () => { return session.sql('CALL multi()') .execute() .then(result => { expect(result.fetchOne()).to.deep.equal(['foo', 'pending']); expect(result.nextResult()).to.equal(true); expect(result.nextResult()).to.equal(true); expect(result.nextResult()).to.equal(false); return expect(result.fetchOne()).to.not.exist; }); });
it('should explain a cursor', async() => { const explained = await db.a.findAsCursor({}) .sort({ name : 1}) .limit(1) .explain(); expect(explained).to.exist; });
it('should save a document', async() => { const doc = await db.a.save({name: 'Charizard', type: 'fire'}); expect(doc._id).to.exist; expect(doc.name).to.equal('Charizard'); doc.type = 'flying'; const updatedDoc = await db.a.save(doc); expect(updatedDoc._id).to.exist; expect(updatedDoc.type).to.equal('flying'); });
it('fails to parse a hosts file with an entry of a non-string password', function() { var hosts = cli.parseHosts(__dirname + "/../../fixtures/cli/fake-hosts.invalid-4.json"); expect(hosts.error).to.exist; expect(hosts.error).to.have.string("INVALID: an entry's password is not a string"); });
it('should keep state until finished', () => { recorder.record(record(rootId, 1, new Annotation.ClientSend())); expect(pendingSpan(rootId)).to.exist; // eslint-disable-line no-unused-expressions recorder.record(record(rootId, 3, new Annotation.ClientRecv())); expect(pendingSpan(rootId)).to.not.exist; // eslint-disable-line no-unused-expressions popSpan(); // consume the span created above. });