Update Mocha and Chai to latest

This commit is contained in:
Miroslav Bajtoš 2018-06-12 16:44:24 +02:00
parent a695cb22e1
commit 284e0111b7
No known key found for this signature in database
GPG Key ID: 6F2304BA9361C7E3
2 changed files with 14 additions and 8 deletions

View File

@ -30,10 +30,10 @@
"uuid": "^3.0.1"
},
"devDependencies": {
"chai": "~3.5.0",
"chai": "^4.1.2",
"eslint": "^4.19.1",
"eslint-config-loopback": "^10.0.0",
"loopback-datasource-juggler": "^3.12.0",
"mocha": "^3.2.0"
"mocha": "^5.2.0"
}
}

View File

@ -173,24 +173,26 @@ describe('transactions', function() {
});
describe('timeout', function() {
const TIMEOUT = 50;
before(function() {
// Reset the collection
db.connector.data = {};
});
var post = {title: 't3', content: 'c3'};
before(createPostInTx(post, 50));
beforeEach(createPostInTx(post, TIMEOUT));
it('should report timeout', function(done) {
setTimeout(function() {
// wait until the "create post" transaction times out
setTimeout(runTheTest, TIMEOUT * 3);
function runTheTest() {
Post.find({where: {title: 't3'}}, {transaction: currentTx},
function(err, posts) {
if (err) return done(err);
expect(posts.length).to.be.eql(1);
expect(err).to.match(/transaction.*not active/);
done();
});
}, 300);
done();
}
});
it('should invoke the timeout hook', function(done) {
@ -198,6 +200,10 @@ describe('transactions', function() {
next();
done();
});
// If the event is not fired quickly enough, then the test can
// quickly fail - no need to wait full two seconds (Mocha's default)
this.timeout(TIMEOUT * 3);
});
});