@@ -20,6 +20,7 @@ import {
20
20
valueToWei ,
21
21
weiToValue ,
22
22
} from '../../../../utils/convert' ;
23
+ import { Partition } from '../../../../types' ;
23
24
24
25
describe ( 'LockUpTransferManagerWrapper' , ( ) => {
25
26
let target : LockUpTransferManagerWrapper ;
@@ -511,6 +512,64 @@ describe('LockUpTransferManagerWrapper', () => {
511
512
} ) ;
512
513
} ) ;
513
514
515
+ describe ( 'getTokensByPartition' , ( ) => {
516
+ test ( 'should call to getTokensByPartition' , async ( ) => {
517
+ const expectedDecimalsResult = new BigNumber ( 18 ) ;
518
+ const expectedResult = valueToWei ( new BigNumber ( 100 ) , expectedDecimalsResult ) ;
519
+ const mockedParams = {
520
+ partition : Partition . Unlocked ,
521
+ tokenHolder : '0x8888888888888888888888888888888888888888' ,
522
+ additionalBalance : new BigNumber ( 10 ) ,
523
+ } ;
524
+
525
+ // Security Token Address expected
526
+ const expectedSecurityTokenAddress = '0x3333333333333333333333333333333333333333' ;
527
+ // Setup get Security Token Address
528
+ const mockedGetSecurityTokenAddressMethod = mock ( MockedCallMethod ) ;
529
+ when ( mockedContract . securityToken ) . thenReturn ( instance ( mockedGetSecurityTokenAddressMethod ) ) ;
530
+ when ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . thenResolve ( expectedSecurityTokenAddress ) ;
531
+ when ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . thenResolve (
532
+ instance ( mockedSecurityTokenContract ) ,
533
+ ) ;
534
+ const mockedSecurityTokenDecimalsMethod = mock ( MockedCallMethod ) ;
535
+ when ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . thenResolve ( expectedDecimalsResult ) ;
536
+ when ( mockedSecurityTokenContract . decimals ) . thenReturn ( instance ( mockedSecurityTokenDecimalsMethod ) ) ;
537
+
538
+ // Mocked method
539
+ const mockedMethod = mock ( MockedCallMethod ) ;
540
+ // Stub the method
541
+ when ( mockedContract . getTokensByPartition ) . thenReturn ( instance ( mockedMethod ) ) ;
542
+ // Stub the request
543
+ when (
544
+ mockedMethod . callAsync (
545
+ mockedParams . partition ,
546
+ mockedParams . tokenHolder ,
547
+ objectContaining ( valueToWei ( mockedParams . additionalBalance , expectedDecimalsResult ) ) ,
548
+ ) ,
549
+ ) . thenResolve ( expectedResult ) ;
550
+
551
+ // Real call
552
+ const result = await target . getTokensByPartition ( mockedParams ) ;
553
+ // Result expectation
554
+ expect ( result ) . toEqual ( weiToValue ( expectedResult , expectedDecimalsResult ) ) ;
555
+
556
+ // Verifications
557
+ verify ( mockedContract . getTokensByPartition ) . once ( ) ;
558
+ verify (
559
+ mockedMethod . callAsync (
560
+ mockedParams . partition ,
561
+ mockedParams . tokenHolder ,
562
+ objectContaining ( valueToWei ( mockedParams . additionalBalance , expectedDecimalsResult ) ) ,
563
+ ) ,
564
+ ) . once ( ) ;
565
+ verify ( mockedContract . securityToken ) . once ( ) ;
566
+ verify ( mockedGetSecurityTokenAddressMethod . callAsync ( ) ) . once ( ) ;
567
+ verify ( mockedContractFactory . getSecurityTokenContract ( expectedSecurityTokenAddress ) ) . once ( ) ;
568
+ verify ( mockedSecurityTokenDecimalsMethod . callAsync ( ) ) . once ( ) ;
569
+ verify ( mockedSecurityTokenContract . decimals ) . once ( ) ;
570
+ } ) ;
571
+ } ) ;
572
+
514
573
describe ( 'verifyTransfer' , ( ) => {
515
574
test ( 'should verify Transfer' , async ( ) => {
516
575
const statusCode = new BigNumber ( 2 ) ;
0 commit comments