File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
tests/Contexts/Shared/infrastructure Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 11import { MongoClientFactory } from '../../../../src/Contexts/Shared/infrastructure/persistence/mongo/MongoClientFactory' ;
22import { MongoClient } from 'mongodb' ;
33
4- describe ( 'MongoClientFactory ' , ( ) => {
4+ describe ( 'Create a client ' , ( ) => {
55 const factory = MongoClientFactory ;
66 let client : MongoClient ;
77
@@ -13,12 +13,24 @@ describe('MongoClientFactory', () => {
1313 await client . close ( ) ;
1414 } ) ;
1515
16- it ( 'creates a new client if it does not exist ' , ( ) => {
16+ it ( 'creates a new client with the connection already established ' , ( ) => {
1717 expect ( client ) . toBeInstanceOf ( MongoClient ) ;
18+ expect ( client . isConnected ( ) ) . toBeTruthy ( ) ;
1819 } ) ;
1920
20- it ( 'creates a new client with existing name should return existing client' , async ( ) => {
21+ it ( 'creates a new client if it does not exist a client with the given name' , async ( ) => {
22+ const newClient = await factory . createClient ( 'test2' ) ;
23+
24+ expect ( newClient ) . not . toBe ( client ) ;
25+
26+ await newClient . close ( ) ;
27+ } ) ;
28+
29+ it ( 'returns a client if it already exists' , async ( ) => {
2130 const newClient = await factory . createClient ( 'test' ) ;
31+
2232 expect ( newClient ) . toBe ( client ) ;
33+
34+ await newClient . close ( ) ;
2335 } ) ;
2436} ) ;
You can’t perform that action at this time.
0 commit comments