it('wrong value is skipped charsetNumber', () => { const result = new ConnOptions( 'mariadb://root:pass@example.com:3307/db?wrongOption=false&ssl=true&dateStrings=true&charsetNumber=aaa' ); assert.equal(result.database, 'db'); assert.isUndefined(result.charsetNumber); });
describe('Unit: TasksManager::done', () => { it('must correct done task for particular hostname key', () => { const tasksManager = new TasksManager(); const task = {}; tasksManager._tasks.set(addresses.INET_HOST1, task); tasksManager.done(addresses.INET_HOST1); assert.isUndefined(tasksManager._tasks.get(addresses.INET_HOST1)); }); });
it('GET/HTTPS/ERROR/WRONG HOST [no reject]', (done) => { request({ url: 'https://wrong.host.badssl.com/' }, (error, resp) => { assert.isUndefined(error, 'no error'); assert.equal(resp.statusCode, 200, 'statusCode: 200'); assert.equal(resp.status, 200, 'status: 200'); assert.isOk(resp.body.includes('wrong.host.badssl.com'), 'Has correct body response'); done(); }); });
describe('#setVerbose()', function () { it('shows verbose information', function () { var results = scanner().setVerbose(false).parseText('text total 6,000.00 date 2016-08-13') assert.isUndefined(results.verbose) results = scanner().setVerbose(true).parseText('text total 6,000.00 date 2016-08-13') assert.isDefined(results.verbose) }) })
it('Can remove an index', function (done) { d.ensureIndex({ fieldName: 'e' }, function (err) { assert.isNull(err); Object.keys(d.indexes).length.should.equal(2); assert.isNotNull(d.indexes.e); d.removeIndex("e", function (err) { assert.isNull(err); Object.keys(d.indexes).length.should.equal(1); assert.isUndefined(d.indexes.e); done(); }); }); });
it('GET/text-plain', (done) => { request({ url: TEST_URL + '/text-plain' }, (error, resp) => { assert.isOk(true, 'got response'); assert.isUndefined(error, 'no error presented'); assert.equal(resp.body, 'plain text response', 'Body content'); assert.equal(resp.statusCode, 200, 'statusCode: 200'); assert.equal(resp.status, 200, 'status: 200'); assert.isOk(resp.headers['content-type'].includes('text/plain'), 'Correct headers Object is presented'); done(); }); });
it("If timestampData option not set, don't create a createdAt and a updatedAt field", function (done) { d.insert({ hello: 'world' }, function (err, insertedDoc) { Object.keys(insertedDoc).length.should.equal(2); assert.isUndefined(insertedDoc.createdAt); assert.isUndefined(insertedDoc.updatedAt); d.find({}, function (err, docs) { docs.length.should.equal(1); assert.deepEqual(docs[0], insertedDoc); done(); }); }); });
it( 'should silently fail if provided an out-of-bounds index', function test() { mat.iset( 1e5, 987 ); assert.isUndefined( mat.iget( 1e5 ) ); mat.iset( -1e5, 789 ); assert.isUndefined( mat.iget( -1e5 ) ); });
it('If an error is thrown by a modifier, the database state is not changed', function (done) { d.insert({ hello: 'world' }, function (err, newDoc) { d.update({}, { $inc: { hello: 4 } }, {}, function (err, nr) { assert.isDefined(err); assert.isUndefined(nr); d.find({}, function (err, docs) { assert.deepEqual(docs, [ { _id: newDoc._id, hello: 'world' } ]); done(); }); }); }); });
it('undefined fields are removed when serialized', function() { var a = { bloup: undefined, hello: 'world' } , b = model.serialize(a) , c = model.deserialize(b) ; Object.keys(c).length.should.equal(1); c.hello.should.equal('world'); assert.isUndefined(c.bloup); });
it('Returns an error if the query is not well formed', function (done) { d.insert({ hello: 'world' }, function () { d.remove({ $or: { hello: 'world' } }, {}, function (err, nr, upsert) { assert.isDefined(err); assert.isUndefined(nr); assert.isUndefined(upsert); done(); }); }); });
it('GET/HTTP/httpbin/absolute-redirect/10 [follow]', (done) => { request({ method: 'GET', url: 'http://httpbin.org/absolute-redirect/10' }, (error, resp) => { assert.isUndefined(resp, 'no response'); assert.equal(error.statusCode, 429, 'statusCode: 429'); assert.equal(error.status, 429, 'status: 429'); done(); }); });
it('Returns an error if the query is not well formed', function (done) { d.insert({ hello: 'world' }, function () { d.update({ $or: { hello: 'world' } }, { a: 1 }, {}, function (err, nr, upsert) { assert.isDefined(err); assert.isUndefined(nr); assert.isUndefined(upsert); done(); }); }); });
describe('Unit: TasksManager::done', () => { it('must correct done task for particular hostname key', () => { const tasksManager = new TasksManager(); const task = {}; tasksManager._tasks.set(addresses.INET_HOST1, task); tasksManager.done(addresses.INET_HOST1); assert.isUndefined(tasksManager._tasks.get(addresses.INET_HOST1)); }); });
it('GET/HTTPS/ERROR/no-common-name [no reject]', (done) => { request({ url: 'https://no-common-name.badssl.com/' }, (error, resp) => { assert.isUndefined(error, 'no error'); assert.equal(resp.statusCode, 200, 'statusCode: 200'); assert.equal(resp.status, 200, 'status: 200'); assert.isOk(resp.body.includes('no-common-name.badssl.com'), 'Has correct body response'); done(); }); });