@@ -350,15 +350,55 @@ it('Should return the same pool when the profile and authentication is the same'
350350
351351it ( 'Should return new user pool if user pool not exist' , async ( ) => {
352352 // Arrange
353+ const profile1 = pg . getProfile ( 'profile1' ) ;
354+ const database = < string > profile1 . connection . database ;
353355 mockDataSource = new MockCannerDataSource ( { } , '' , [
354356 pg . getProfile ( 'profile1' ) ,
355357 ] ) ;
356358 await mockDataSource . activate ( ) ;
357359 // Act
358360 const pool1 = mockDataSource . getPool ( 'profile1' ) ;
359361 const pool2 = mockDataSource . getPool ( 'profile1' , 'my-authentication' ) ;
362+ const userPool = mockDataSource . getUserPool ( 'my-authentication' , database ) ;
360363 // Assert
361364 expect ( pool1 == pool2 ) . toBeFalsy ( ) ;
365+ expect ( userPool === pool2 ) . toBeTruthy ( ) ;
366+ } , 30000 ) ;
367+
368+ it ( 'Should return existing user pool if user pool exist' , async ( ) => {
369+ // Arrange
370+ const profile1 = pg . getProfile ( 'profile1' ) ;
371+ const database = < string > profile1 . connection . database ;
372+ mockDataSource = new MockCannerDataSource ( { } , '' , [
373+ pg . getProfile ( 'profile1' ) ,
374+ ] ) ;
375+ await mockDataSource . activate ( ) ;
376+
377+ // Act
378+ const pool = mockDataSource . getPool ( 'profile1' , 'my-authentication' ) ;
379+ const userPool = mockDataSource . getUserPool ( 'my-authentication' , database ) ;
380+ // Assert
381+ expect ( userPool === pool ) . toBeTruthy ( ) ;
382+ } , 30000 ) ;
383+
384+ it ( 'Should return new user pool if user pool exist but not match' , async ( ) => {
385+ // Arrange
386+ const profile1 = pg . getProfile ( 'profile1' ) ;
387+ const database = < string > profile1 . connection . database ;
388+ mockDataSource = new MockCannerDataSource ( { } , '' , [
389+ pg . getProfile ( 'profile1' ) ,
390+ ] ) ;
391+ await mockDataSource . activate ( ) ;
392+
393+ // Act
394+ expect ( mockDataSource . getUserPool ( 'my-authentication' , database ) ) . toBe (
395+ undefined
396+ ) ;
397+ mockDataSource . getPool ( 'profile1' , 'my-authentication' ) ;
398+ // Assert
399+ expect (
400+ mockDataSource . getUserPool ( 'my-authentication' , database )
401+ ) . toBeDefined ( ) ;
362402} , 30000 ) ;
363403
364404it ( 'Should return different pool with different authentication even the profile is the same' , async ( ) => {
0 commit comments