@@ -350,15 +350,55 @@ it('Should return the same pool when the profile and authentication is the same'
350
350
351
351
it ( 'Should return new user pool if user pool not exist' , async ( ) => {
352
352
// Arrange
353
+ const profile1 = pg . getProfile ( 'profile1' ) ;
354
+ const database = < string > profile1 . connection . database ;
353
355
mockDataSource = new MockCannerDataSource ( { } , '' , [
354
356
pg . getProfile ( 'profile1' ) ,
355
357
] ) ;
356
358
await mockDataSource . activate ( ) ;
357
359
// Act
358
360
const pool1 = mockDataSource . getPool ( 'profile1' ) ;
359
361
const pool2 = mockDataSource . getPool ( 'profile1' , 'my-authentication' ) ;
362
+ const userPool = mockDataSource . getUserPool ( 'my-authentication' , database ) ;
360
363
// Assert
361
364
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 ( ) ;
362
402
} , 30000 ) ;
363
403
364
404
it ( 'Should return different pool with different authentication even the profile is the same' , async ( ) => {
0 commit comments