test: make status test more robust
Rework assertions to report helpful messages on failure. Increase the "elapsed" limit from 100ms to 300ms to support our slow CI machines.
This commit is contained in:
parent
48205fb2bd
commit
caaa296a82
|
@ -12,6 +12,7 @@ var loopback = require('../');
|
|||
var PersistedModel = loopback.PersistedModel;
|
||||
|
||||
var describe = require('./util/describe');
|
||||
var expect = require('chai').expect;
|
||||
var it = require('./util/it');
|
||||
|
||||
describe('app', function() {
|
||||
|
@ -937,18 +938,14 @@ describe('app', function() {
|
|||
.end(function(err, res) {
|
||||
if (err) return done(err);
|
||||
|
||||
assert.equal(typeof res.body, 'object');
|
||||
assert(res.body.started);
|
||||
// The number can be 0
|
||||
assert(res.body.uptime !== undefined);
|
||||
expect(res.body).to.be.an('object');
|
||||
expect(res.body).to.have.property('started');
|
||||
expect(res.body.uptime, 'uptime').to.be.gte(0);
|
||||
|
||||
var elapsed = Date.now() - Number(new Date(res.body.started));
|
||||
|
||||
// elapsed should be a positive number...
|
||||
assert(elapsed >= 0);
|
||||
|
||||
// less than 100 milliseconds
|
||||
assert(elapsed < 100);
|
||||
// elapsed should be a small positive number...
|
||||
expect(elapsed, 'elapsed').to.be.within(0, 300);
|
||||
|
||||
done();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue