From 04e26fae5cf8da8128e926c1d7bd88818ca31937 Mon Sep 17 00:00:00 2001 From: Supasate Choochaisri Date: Thu, 5 May 2016 11:09:06 +0700 Subject: [PATCH] Separate error-checking and next/done logic from other logic in the test suite Signed-off-by: Supasate Choochaisri --- test/access-control.integration.js | 2 + test/access-token.test.js | 30 ++++ test/acl.test.js | 3 + test/app.test.js | 61 +++++++ test/change-stream.test.js | 3 + test/change.test.js | 39 +++++ test/checkpoint.test.js | 9 + test/e2e/remote-connector.e2e.js | 4 + test/e2e/replication.e2e.js | 2 + test/email.test.js | 2 + test/error-handler.test.js | 3 + test/helpers/loopback-testing-helper.js | 8 + test/hidden-properties.test.js | 4 + test/integration.test.js | 2 + test/loopback.test.js | 4 + test/memory.test.js | 1 + test/model.application.test.js | 18 ++ test/model.test.js | 39 ++++- test/registries.test.js | 1 + test/relations.integration.js | 163 ++++++++++++++++-- test/remote-connector.test.js | 4 + test/remoting-coercion.test.js | 2 + test/remoting.integration.js | 2 + test/replication.rest.test.js | 50 ++++++ test/replication.test.js | 105 ++++++++++++ test/rest.middleware.test.js | 27 ++- test/role.test.js | 27 +++ test/user.integration.js | 43 +++-- test/user.test.js | 211 ++++++++++++++---------- test/util/model-tests.js | 12 ++ 30 files changed, 753 insertions(+), 128 deletions(-) diff --git a/test/access-control.integration.js b/test/access-control.integration.js index feede70f..a08b147e 100644 --- a/test/access-control.integration.js +++ b/test/access-control.integration.js @@ -127,6 +127,7 @@ describe('access control - integration', function() { var userCounter; function newUserData() { userCounter = userCounter ? ++userCounter : 1; + return { email: 'new-' + userCounter + '@test.test', password: 'test', @@ -204,6 +205,7 @@ describe('access control - integration', function() { balance: 100, }, function(err, act) { self.url = '/api/accounts/' + act.id; + done(); }); }); diff --git a/test/access-token.test.js b/test/access-token.test.js index 051cc94c..bca91d4e 100644 --- a/test/access-token.test.js +++ b/test/access-token.test.js @@ -150,6 +150,7 @@ describe('loopback.token(options)', function() { .end(function(err, res) { assert(!err); assert.deepEqual(res.body, { userId: userId }); + done(); }); }); @@ -165,6 +166,7 @@ describe('loopback.token(options)', function() { .end(function(err, res) { assert(!err); assert.deepEqual(res.body, { userId: userId, state: 1 }); + done(); }); }); @@ -180,6 +182,7 @@ describe('loopback.token(options)', function() { .end(function(err, res) { assert(!err); assert.deepEqual(res.body, { userId: userId, state: 1 }); + done(); }); }); @@ -188,6 +191,7 @@ describe('loopback.token(options)', function() { var tokenStub = { id: 'stub id' }; app.use(function(req, res, next) { req.accessToken = tokenStub; + next(); }); app.use(loopback.token({ model: Token })); @@ -200,7 +204,9 @@ describe('loopback.token(options)', function() { .expect(200) .end(function(err, res) { if (err) return done(err); + expect(res.body).to.eql(tokenStub); + done(); }); }); @@ -211,6 +217,7 @@ describe('loopback.token(options)', function() { var tokenStub = { id: 'stub id' }; app.use(function(req, res, next) { req.accessToken = tokenStub; + next(); }); app.use(loopback.token({ model: Token })); @@ -223,7 +230,9 @@ describe('loopback.token(options)', function() { .expect(200) .end(function(err, res) { if (err) return done(err); + expect(res.body).to.eql(tokenStub); + done(); }); }); @@ -234,6 +243,7 @@ describe('loopback.token(options)', function() { var tokenStub = { id: 'stub id' }; app.use(function(req, res, next) { req.accessToken = tokenStub; + next(); }); app.use(loopback.token({ @@ -249,7 +259,9 @@ describe('loopback.token(options)', function() { .expect(200) .end(function(err, res) { if (err) return done(err); + expect(res.body).to.eql(tokenStub); + done(); }); }); @@ -262,6 +274,7 @@ describe('loopback.token(options)', function() { app.use(function(req, res, next) { req.accessToken = tokenStub; + next(); }); app.use(loopback.token({ @@ -278,12 +291,14 @@ describe('loopback.token(options)', function() { .expect(200) .end(function(err, res) { if (err) return done(err); + expect(res.body).to.eql({ id: token.id, ttl: token.ttl, userId: token.userId, created: token.created.toJSON(), }); + done(); }); }); @@ -306,6 +321,7 @@ describe('AccessToken', function() { it('should be validateable', function(done) { this.token.validate(function(err, isValid) { assert(isValid); + done(); }); }); @@ -321,7 +337,9 @@ describe('AccessToken', function() { Token.findForRequest(req, function(err, token) { if (err) return done(err); + expect(token.id).to.eql(expectedTokenId); + done(); }); }); @@ -355,9 +373,11 @@ describe('app.enableAuth()', function() { if (err) { return done(err); } + var errorResponse = res.body.error; assert(errorResponse); assert.equal(errorResponse.code, 'AUTHORIZATION_REQUIRED'); + done(); }); }); @@ -371,9 +391,11 @@ describe('app.enableAuth()', function() { if (err) { return done(err); } + var errorResponse = res.body.error; assert(errorResponse); assert.equal(errorResponse.code, 'ACCESS_DENIED'); + done(); }); }); @@ -387,9 +409,11 @@ describe('app.enableAuth()', function() { if (err) { return done(err); } + var errorResponse = res.body.error; assert(errorResponse); assert.equal(errorResponse.code, 'MODEL_NOT_FOUND'); + done(); }); }); @@ -403,9 +427,11 @@ describe('app.enableAuth()', function() { if (err) { return done(err); } + var errorResponse = res.body.error; assert(errorResponse); assert.equal(errorResponse.code, 'AUTHORIZATION_REQUIRED'); + done(); }); }); @@ -436,7 +462,9 @@ describe('app.enableAuth()', function() { .expect('Content-Type', /json/) .end(function(err, res) { if (err) return done(err); + expect(res.body.token.id).to.eql(token.id); + done(); }); }); @@ -446,7 +474,9 @@ function createTestingToken(done) { var test = this; Token.create({ userId: '123' }, function(err, token) { if (err) return done(err); + test.token = token; + done(); }); } diff --git a/test/acl.test.js b/test/acl.test.js index 63fa1637..e774e3e4 100644 --- a/test/acl.test.js +++ b/test/acl.test.js @@ -417,7 +417,9 @@ describe('access check', function() { MyTestModel.beforeRemote('find', function(ctx, next) { // ensure this is called after checkAccess if (!checkAccessCalled) return done(new Error('incorrect order')); + beforeHookCalled = true; + next(); }); @@ -426,6 +428,7 @@ describe('access check', function() { .end(function(err, result) { assert(beforeHookCalled, 'the before hook should be called'); assert(checkAccessCalled, 'checkAccess should have been called'); + done(); }); }); diff --git a/test/app.test.js b/test/app.test.js index 7de8f962..d76287cf 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -36,10 +36,12 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql([ 'initial', 'session', 'auth', 'parse', 'main', 'routes', 'files', 'final', ]); + done(); }); }); @@ -50,7 +52,9 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['first', 'second']); + done(); }); }); @@ -62,7 +66,9 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['routes:before', 'main', 'routes:after']); + done(); }); }); @@ -82,7 +88,9 @@ describe('app', function() { expect(found).have.property('phase', 'routes:before'); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['my-handler', 'extra-handler']); + done(); }); }); @@ -100,7 +108,9 @@ describe('app', function() { expect(found).have.property('phase', 'routes:before'); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['my-handler']); + done(); }); }); @@ -118,7 +128,9 @@ describe('app', function() { expect(found).have.property('phase', 'routes:before'); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['my-handler']); + done(); }); }); @@ -128,6 +140,7 @@ describe('app', function() { app.middleware('initial', function(req, res, next) { steps.push('initial'); + next(expectedError); }); @@ -135,12 +148,15 @@ describe('app', function() { app.use(function errorHandler(err, req, res, next) { expect(err).to.equal(expectedError); steps.push('error'); + next(); }); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(['initial', 'error']); + done(); }); }); @@ -154,6 +170,7 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { expect(err).to.equal(expectedError); + done(); }); }); @@ -172,12 +189,15 @@ describe('app', function() { app.middleware('initial', function(err, req, res, next) { handledError = err; + next(); }); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(handledError).to.equal(expectedError); + done(); }); }); @@ -190,7 +210,9 @@ describe('app', function() { function(url, next) { executeMiddlewareHandlers(app, url, next); }, function(err) { if (err) return done(err); + expect(steps).to.eql(['/scope', '/scope/item']); + done(); }); }); @@ -203,7 +225,9 @@ describe('app', function() { function(url, next) { executeMiddlewareHandlers(app, url, next); }, function(err) { if (err) return done(err); + expect(steps).to.eql(['/a', '/b']); + done(); }); }); @@ -216,7 +240,9 @@ describe('app', function() { function(url, next) { executeMiddlewareHandlers(app, url, next); }, function(err) { if (err) return done(err); + expect(steps).to.eql(['/a', '/b', '/scope']); + done(); }); }); @@ -224,12 +250,15 @@ describe('app', function() { it('sets req.url to a sub-path', function(done) { app.middleware('initial', ['/scope'], function(req, res, next) { steps.push(req.url); + next(); }); executeMiddlewareHandlers(app, '/scope/id', function(err) { if (err) return done(err); + expect(steps).to.eql(['/id']); + done(); }); }); @@ -240,11 +269,13 @@ describe('app', function() { app.middleware('initial', function(rq, rs, next) { req = rq; res = rs; + next(); }); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(getObjectAndPrototypeKeys(req), 'request').to.include.members([ 'accepts', 'get', @@ -274,12 +305,15 @@ describe('app', function() { var reqProps; app.middleware('initial', function(req, res, next) { reqProps = { baseUrl: req.baseUrl, originalUrl: req.originalUrl }; + next(); }); executeMiddlewareHandlers(app, '/test/url', function(err) { if (err) return done(err); + expect(reqProps).to.eql({ baseUrl: '', originalUrl: '/test/url' }); + done(); }); }); @@ -291,7 +325,9 @@ describe('app', function() { executeMiddlewareHandlers(app, '/test', function(err) { if (err) return done(err); + expect(steps).to.eql(['route', 'files']); + done(); }); }); @@ -311,7 +347,9 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { if (err) return done; + expect(steps).to.eql(numbers); + done(); }); }); @@ -324,6 +362,7 @@ describe('app', function() { mountpath: req.app.mountpath, parent: req.app.parent, }; + next(); }); subapp.on('mount', function() { mountWasEmitted = true; }); @@ -332,11 +371,13 @@ describe('app', function() { executeMiddlewareHandlers(app, '/mountpath/test', function(err) { if (err) return done(err); + expect(mountWasEmitted, 'mountWasEmitted').to.be.true; expect(data).to.eql({ mountpath: '/mountpath', parent: app, }); + done(); }); }); @@ -349,25 +390,30 @@ describe('app', function() { subapp.use(function verifyTestAssumptions(req, res, next) { expect(req.__proto__).to.not.equal(expected.req); expect(res.__proto__).to.not.equal(expected.res); + next(); }); app.middleware('initial', function saveOriginalValues(req, res, next) { expected.req = req.__proto__; expected.res = res.__proto__; + next(); }); app.middleware('routes', subapp); app.middleware('final', function saveActualValues(req, res, next) { actual.req = req.__proto__; actual.res = res.__proto__; + next(); }); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(actual.req, 'req').to.equal(expected.req); expect(actual.res, 'res').to.equal(expected.res); + done(); }); }); @@ -382,6 +428,7 @@ describe('app', function() { function pathSavingHandler() { return function(req, res, next) { steps.push(req.originalUrl); + next(); }; } @@ -405,6 +452,7 @@ describe('app', function() { var args = Array.prototype.slice.apply(arguments); return function(req, res, next) { steps.push(args); + next(); }; }; @@ -455,12 +503,14 @@ describe('app', function() { executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql([ ['before'], [expectedConfig], ['after', 2], [{ x: 1 }], ]); + done(); }); }); @@ -471,6 +521,7 @@ describe('app', function() { function factory() { return function(req, res, next) { steps.push(req.originalUrl); + next(); }; }, @@ -484,7 +535,9 @@ describe('app', function() { function(url, next) { executeMiddlewareHandlers(app, url, next); }, function(err) { if (err) return done(err); + expect(steps).to.eql(['/a', '/b', '/scope']); + done(); }); }); @@ -541,13 +594,16 @@ describe('app', function() { names.forEach(function(it) { app.middleware(it, function(req, res, next) { steps.push(it); + next(); }); }); executeMiddlewareHandlers(app, function(err) { if (err) return done(err); + expect(steps).to.eql(names); + done(); }); } @@ -777,6 +833,7 @@ describe('app', function() { app.listen(function() { expect(app.get('port'), 'port').to.not.equal(0); + done(); }); }); @@ -790,6 +847,7 @@ describe('app', function() { var host = process.platform === 'win32' ? 'localhost' : app.get('host'); var expectedUrl = 'http://' + host + ':' + app.get('port') + '/'; expect(app.get('url'), 'url').to.equal(expectedUrl); + done(); }); }); @@ -800,6 +858,7 @@ describe('app', function() { app.listen(0, '127.0.0.1', function() { expect(app.get('port'), 'port').to.not.equal(0).and.not.equal(1); expect(this.address().address).to.equal('127.0.0.1'); + done(); }); }); @@ -810,6 +869,7 @@ describe('app', function() { app.set('port', 1); app.listen(0).on('listening', function() { expect(app.get('port'), 'port') .to.not.equal(0).and.not.equal(1); + done(); }); } @@ -824,6 +884,7 @@ describe('app', function() { app.listen() .on('listening', function() { expect(this.address().address).to.equal('127.0.0.1'); + done(); }); }); diff --git a/test/change-stream.test.js b/test/change-stream.test.js index e3495b06..c2ecd56d 100644 --- a/test/change-stream.test.js +++ b/test/change-stream.test.js @@ -22,6 +22,7 @@ describe('PersistedModel.createChangeStream()', function() { changes.on('data', function(change) { expect(change.type).to.equal('create'); changes.destroy(); + done(); }); @@ -36,6 +37,7 @@ describe('PersistedModel.createChangeStream()', function() { changes.on('data', function(change) { expect(change.type).to.equal('update'); changes.destroy(); + done(); }); newScore.updateAttributes({ @@ -52,6 +54,7 @@ describe('PersistedModel.createChangeStream()', function() { changes.on('data', function(change) { expect(change.type).to.equal('remove'); changes.destroy(); + done(); }); diff --git a/test/change.test.js b/test/change.test.js index dbe6b500..f1f429fc 100644 --- a/test/change.test.js +++ b/test/change.test.js @@ -32,9 +32,11 @@ describe('Change', function() { }; TestModel.create(test.data, function(err, model) { if (err) return done(err); + test.model = model; test.modelId = model.id; test.revisionForModel = Change.revisionForInst(model); + done(); }); }); @@ -65,6 +67,7 @@ describe('Change', function() { var test = this; Change.rectifyModelChanges(this.modelName, [this.modelId], function(err, trackedChanges) { if (err) return done(err); + done(); }); }); @@ -73,6 +76,7 @@ describe('Change', function() { var test = this; Change.find(function(err, trackedChanges) { assert.equal(trackedChanges[0].modelId, test.modelId.toString()); + done(); }); }); @@ -80,6 +84,7 @@ describe('Change', function() { it('should only create one change', function(done) { Change.count(function(err, count) { assert.equal(count, 1); + done(); }); }); @@ -102,6 +107,7 @@ describe('Change', function() { Change.find() .then(function(trackedChanges) { assert.equal(trackedChanges[0].modelId, test.modelId.toString()); + done(); }) .catch(done); @@ -111,6 +117,7 @@ describe('Change', function() { Change.count() .then(function(count) { assert.equal(count, 1); + done(); }) .catch(done); @@ -124,7 +131,9 @@ describe('Change', function() { var test = this; Change.findOrCreateChange(this.modelName, this.modelId, function(err, result) { if (err) return done(err); + test.result = result; + done(); }); }); @@ -133,7 +142,9 @@ describe('Change', function() { var test = this; Change.findById(this.result.id, function(err, change) { if (err) return done(err); + assert.equal(change.id, test.result.id); + done(); }); }); @@ -145,6 +156,7 @@ describe('Change', function() { Change.findOrCreateChange(this.modelName, this.modelId) .then(function(result) { test.result = result; + done(); }) .catch(done); @@ -154,7 +166,9 @@ describe('Change', function() { var test = this; Change.findById(this.result.id, function(err, change) { if (err) return done(err); + assert.equal(change.id, test.result.id); + done(); }); }); @@ -168,6 +182,7 @@ describe('Change', function() { modelId: test.modelId, }, function(err, change) { test.existingChange = change; + done(); }); }); @@ -176,7 +191,9 @@ describe('Change', function() { var test = this; Change.findOrCreateChange(this.modelName, this.modelId, function(err, result) { if (err) return done(err); + test.result = result; + done(); }); }); @@ -184,6 +201,7 @@ describe('Change', function() { it('should find the entry', function(done) { var test = this; assert.equal(test.existingChange.id, test.result.id); + done(); }); }); @@ -199,6 +217,7 @@ describe('Change', function() { }, function(err, ch) { change = ch; + done(err); }); }); @@ -207,6 +226,7 @@ describe('Change', function() { var test = this; change.rectify(function(err, ch) { assert.equal(ch.rev, test.revisionForModel); + done(); }); }); @@ -230,6 +250,7 @@ describe('Change', function() { expect(change.type(), 'type').to.equal('update'); expect(change.prev, 'prev').to.equal(originalRev); expect(change.rev, 'rev').to.equal(test.revisionForModel); + next(); }, ], done); @@ -241,7 +262,9 @@ describe('Change', function() { function checkpoint(next) { TestModel.checkpoint(function(err, inst) { if (err) return next(err); + cp = inst.seq; + next(); }); } @@ -252,6 +275,7 @@ describe('Change', function() { model.name += 'updated'; model.save(function(err) { test.revisionForModel = Change.revisionForInst(model); + next(err); }); } @@ -267,8 +291,10 @@ describe('Change', function() { change.rectify(function(err, c) { if (err) return done(err); + expect(c.rev, 'rev').to.equal(originalRev); // sanity check expect(c.checkpoint, 'checkpoint').to.equal(originalCheckpoint); + done(); }); }); @@ -281,6 +307,7 @@ describe('Change', function() { Change.findOrCreateChange(this.modelName, this.modelId) .then(function(ch) { change = ch; + done(); }) .catch(done); @@ -291,6 +318,7 @@ describe('Change', function() { change.rectify() .then(function(ch) { assert.equal(ch.rev, test.revisionForModel); + done(); }) .catch(done); @@ -307,6 +335,7 @@ describe('Change', function() { change.currentRevision(function(err, rev) { assert.equal(rev, test.revisionForModel); + done(); }); }); @@ -323,6 +352,7 @@ describe('Change', function() { change.currentRevision() .then(function(rev) { assert.equal(rev, test.revisionForModel); + done(); }) .catch(done); @@ -463,8 +493,10 @@ describe('Change', function() { Change.diff(this.modelName, 0, remoteChanges, function(err, diff) { if (err) return done(err); + assert.equal(diff.deltas.length, 1); assert.equal(diff.conflicts.length, 1); + done(); }); }); @@ -483,6 +515,7 @@ describe('Change', function() { .then(function(diff) { assert.equal(diff.deltas.length, 1); assert.equal(diff.conflicts.length, 1); + done(); }) .catch(done); @@ -498,6 +531,7 @@ describe('Change', function() { }; Change.diff(this.modelName, 0, [updateRecord], function(err, diff) { if (err) return done(err); + expect(diff.conflicts, 'conflicts').to.have.length(0); expect(diff.deltas, 'deltas').to.have.length(1); var actual = diff.deltas[0].toObject(); @@ -509,6 +543,7 @@ describe('Change', function() { prev: 'foo', // this is the current local revision rev: 'foo-new', }); + done(); }); }); @@ -525,6 +560,7 @@ describe('Change', function() { // with rev=foo CP=1 Change.diff(this.modelName, 2, [updateRecord], function(err, diff) { if (err) return done(err); + expect(diff.conflicts, 'conflicts').to.have.length(0); expect(diff.deltas, 'deltas').to.have.length(1); var actual = diff.deltas[0].toObject(); @@ -536,6 +572,7 @@ describe('Change', function() { prev: 'foo', // this is the current local revision rev: 'foo-new', }); + done(); }); }); @@ -551,6 +588,7 @@ describe('Change', function() { Change.diff(this.modelName, 0, [updateRecord], function(err, diff) { if (err) return done(err); + expect(diff.conflicts).to.have.length(0); expect(diff.deltas).to.have.length(1); var actual = diff.deltas[0].toObject(); @@ -562,6 +600,7 @@ describe('Change', function() { prev: null, // this is the current local revision rev: 'new-rev', }); + done(); }); }); diff --git a/test/checkpoint.test.js b/test/checkpoint.test.js index fa9ce148..366a8214 100644 --- a/test/checkpoint.test.js +++ b/test/checkpoint.test.js @@ -25,7 +25,9 @@ describe('Checkpoint', function() { function(next) { Checkpoint.current(function(err, seq) { if (err) next(err); + expect(seq).to.equal(3); + next(); }); }, @@ -38,9 +40,12 @@ describe('Checkpoint', function() { function(next) { Checkpoint.current(next); }, ], function(err, list) { if (err) return done(err); + Checkpoint.find(function(err, data) { if (err) return done(err); + expect(data).to.have.length(1); + done(); }); }); @@ -52,6 +57,7 @@ describe('Checkpoint', function() { function(next) { Checkpoint.bumpLastSeq(next); }, ], function(err, list) { if (err) return done(err); + Checkpoint.find(function(err, data) { if (err) return done(err); // The invariant "we have at most 1 checkpoint instance" is preserved @@ -64,6 +70,7 @@ describe('Checkpoint', function() { // should be 2. expect(list.map(function(it) { return it.seq; })) .to.eql([2, 2]); + done(); }); }); @@ -73,6 +80,7 @@ describe('Checkpoint', function() { function(done) { Checkpoint.current(function(err, seq) { expect(seq).to.equal(1); + done(err); }); }); @@ -83,6 +91,7 @@ describe('Checkpoint', function() { // `bumpLastSeq` for the first time not only initializes it to one, // but also increments the initialized value by one. expect(cp.seq).to.equal(2); + done(err); }); }); diff --git a/test/e2e/remote-connector.e2e.js b/test/e2e/remote-connector.e2e.js index eb75f644..65868b2c 100644 --- a/test/e2e/remote-connector.e2e.js +++ b/test/e2e/remote-connector.e2e.js @@ -24,7 +24,9 @@ describe('RemoteConnector', function() { foo: 'bar', }, function(err, inst) { if (err) return done(err); + assert(inst.id); + done(); }); }); @@ -35,7 +37,9 @@ describe('RemoteConnector', function() { }); m.save(function(err, data) { if (err) return done(err); + assert(data.foo === 'bar'); + done(); }); }); diff --git a/test/e2e/replication.e2e.js b/test/e2e/replication.e2e.js index 339fc879..6bf9e31e 100644 --- a/test/e2e/replication.e2e.js +++ b/test/e2e/replication.e2e.js @@ -32,8 +32,10 @@ describe('Replication', function() { }, function(err, created) { LocalTestModel.replicate(0, TestModel, function() { if (err) return done(err); + TestModel.findOne({ n: RANDOM }, function(err, found) { assert.equal(created.id, found.id); + done(); }); }); diff --git a/test/email.test.js b/test/email.test.js index 31ab80bf..aa6ebd60 100644 --- a/test/email.test.js +++ b/test/email.test.js @@ -69,6 +69,7 @@ describe('Email and SMTP', function() { assert(mail.response); assert(mail.envelope); assert(mail.messageId); + done(err); }); }); @@ -86,6 +87,7 @@ describe('Email and SMTP', function() { assert(mail.response); assert(mail.envelope); assert(mail.messageId); + done(err); }); }); diff --git a/test/error-handler.test.js b/test/error-handler.test.js index 45484182..e1d9a790 100644 --- a/test/error-handler.test.js +++ b/test/error-handler.test.js @@ -20,6 +20,7 @@ describe('loopback.errorHandler(options)', function() { .get('/url-does-not-exist') .end(function(err, res) { assert.ok(res.error.text.match(/