Skip to content

Commit 8845b8f

Browse files
committed
Update test coverage for th D librairy
1 parent 6379a71 commit 8845b8f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/lib/db.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ function connect() {
1818
.catch(err => logger.error(err));
1919
}
2020

21-
module.exports = { connect };
21+
function close() {
22+
mongoose.connection.close();
23+
}
24+
25+
module.exports = { connect, close };

test/lib.db.spec.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ const { expect } = require('chai');
22
const db = require('../src/lib/db');
33

44
// DB
5-
describe('DB library', () => {
5+
describe('DB Connect', () => {
66
it('expect "connect" to be a function', (done) => {
77
expect(typeof (db.connect)).to.be.equals('function');
88
done();
99
});
10+
it('expect "connect" to not throw', (done) => {
11+
expect(db.connect).to.not.throw();
12+
db.close();
13+
done();
14+
});
15+
});
16+
17+
describe('DB Close', () => {
18+
it('expect "close" to be a function', (done) => {
19+
expect(typeof (db.close)).to.be.equals('function');
20+
done();
21+
});
22+
it('expect "close" to not throw', (done) => {
23+
expect(db.close).to.not.throw();
24+
done();
25+
});
1026
});

0 commit comments

Comments
 (0)