File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 } ;
Original file line number Diff line number Diff line change @@ -2,9 +2,25 @@ const { expect } = require('chai');
22const 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} ) ;
You can’t perform that action at this time.
0 commit comments