@@ -11,7 +11,7 @@ import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryObject';
11
11
import { CreateErc20DividendDistribution } from '../../procedures/CreateErc20DividendDistribution' ;
12
12
import { Procedure } from '~/procedures/Procedure' ;
13
13
import { PolymathError } from '~/PolymathError' ;
14
- import { ErrorCode , ProcedureType } from '~/types' ;
14
+ import { ErrorCode , ProcedureType } from '~/types' ;
15
15
import { ApproveErc20 } from '../ApproveErc20' ;
16
16
import * as securityTokenFactoryModule from '~/entities/factories/SecurityTokenFactory' ;
17
17
import * as cappedStoFactoryModule from '~/entities/factories/CappedStoFactory' ;
@@ -27,7 +27,6 @@ import * as usdTieredStoFactoryModule from '~/entities/factories/UsdTieredStoFac
27
27
import * as taxWithholdingFactoryModule from '~/entities/factories/TaxWithholdingFactory' ;
28
28
import * as utilsModule from '~/utils' ;
29
29
30
-
31
30
const params1 = {
32
31
symbol : 'TEST1' ,
33
32
name : 'Test Token 1' ,
@@ -199,6 +198,42 @@ describe('CreateErc20DividendDistribution', () => {
199
198
expect ( spyOnAddProcedure . withArgs ( ApproveErc20 ) . callCount ) . toBe ( 1 ) ;
200
199
} ) ;
201
200
201
+ test ( 'should send the transaction to CreateErc20DividendDistribution with taxWitholdings' , async ( ) => {
202
+ target = new CreateErc20DividendDistribution (
203
+ {
204
+ symbol : params1 . symbol ,
205
+ maturityDate : params1 . maturityDate ,
206
+ expiryDate : params1 . expiryDate ,
207
+ erc20Address : params1 . erc20Address ,
208
+ amount : params1 . amount ,
209
+ checkpointIndex : params1 . checkpointIndex ,
210
+ name : params1 . name ,
211
+ taxWithholdings : [
212
+ {
213
+ address : '0x5555555555555555555555555555555555555555' ,
214
+ percentage : 50 ,
215
+ } ,
216
+ ] ,
217
+ } ,
218
+ contextMock . getMockInstance ( )
219
+ ) ;
220
+ const spyOnAddProcedure = sinon . spy ( target , 'addProcedure' ) ;
221
+ const spyOnAddTransaction = sinon . spy ( target , 'addTransaction' ) ;
222
+ // Real call
223
+ await target . prepareTransactions ( ) ;
224
+
225
+ // Verifications
226
+ expect (
227
+ spyOnAddTransaction . withArgs ( erc20DividendsMock . getMockInstance ( ) . setWithholding ) . callCount
228
+ ) . toBe ( 2 ) ;
229
+ expect (
230
+ spyOnAddTransaction . withArgs (
231
+ erc20DividendsMock . getMockInstance ( ) . createDividendWithCheckpointAndExclusions
232
+ ) . callCount
233
+ ) . toBe ( 2 ) ;
234
+ expect ( spyOnAddProcedure . withArgs ( ApproveErc20 ) . callCount ) . toBe ( 1 ) ;
235
+ } ) ;
236
+
202
237
test ( 'should throw if there is no supplied valid security token' , async ( ) => {
203
238
tokenFactoryMock . set (
204
239
'getSecurityTokenInstanceFromTicker' ,
0 commit comments