1
1
import { ImportMock , MockManager } from 'ts-mock-imports' ;
2
- import { SinonStub , stub , spy , restore } from 'sinon' ;
2
+ import { stub , spy , restore } from 'sinon' ;
3
3
import { BigNumber } from '@polymathnetwork/contract-wrappers' ;
4
4
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers' ;
5
5
import * as contextModule from '../../Context' ;
@@ -10,14 +10,9 @@ import { Procedure } from '~/procedures/Procedure';
10
10
import { PolymathError } from '~/PolymathError' ;
11
11
import { ErrorCode , PolyTransactionTag } from '~/types' ;
12
12
13
- const params1 = {
13
+ const params = {
14
14
symbol : 'TEST1' ,
15
- name : 'Test Token 1' ,
16
- amount : new BigNumber ( 1 ) ,
17
- checkpointIndex : 1 ,
18
- maturityDate : new Date ( 2030 , 1 ) ,
19
- expiryDate : new Date ( 2031 , 1 ) ,
20
- address : '0x4444444444444444444444444444444444444444' ,
15
+ storageWalletAddress : '0x5555555555555555555555555555555555555555' ,
21
16
} ;
22
17
23
18
describe ( 'EnableDividendManagers' , ( ) => {
@@ -27,41 +22,30 @@ describe('EnableDividendManagers', () => {
27
22
let tokenFactoryMock : MockManager < tokenFactoryModule . MockedTokenFactoryObject > ;
28
23
let etherDividendsMock : MockManager < contractWrappersModule . EtherDividendCheckpoint_3_0_0 > ;
29
24
let securityTokenMock : MockManager < contractWrappersModule . SecurityToken_3_0_0 > ;
30
- let tokenFactoryMockStub : SinonStub < any , any > ;
31
- let getAttachedModulesMockStub : SinonStub < any , any > ;
32
25
33
26
beforeAll ( ( ) => {
34
- // Mock the context, wrappers, and tokenFactory to test CreateEtherDividendDistribution
27
+ // Mock the context, wrappers, and tokenFactory to test EnableDividendManagers
35
28
contextMock = ImportMock . mockClass ( contextModule , 'Context' ) ;
36
29
wrappersMock = ImportMock . mockClass ( wrappersModule , 'PolymathBase' ) ;
37
30
tokenFactoryMock = ImportMock . mockClass ( tokenFactoryModule , 'MockedTokenFactoryObject' ) ;
38
31
contextMock . set ( 'contractWrappers' , wrappersMock . getMockInstance ( ) ) ;
39
32
wrappersMock . set ( 'tokenFactory' , tokenFactoryMock . getMockInstance ( ) ) ;
40
33
41
34
securityTokenMock = ImportMock . mockClass ( contractWrappersModule , 'SecurityToken_3_0_0' ) ;
42
- securityTokenMock . mock ( 'address' , Promise . resolve ( params1 . address ) ) ;
35
+ securityTokenMock . mock ( 'address' , Promise . resolve ( params . storageWalletAddress ) ) ;
43
36
44
37
etherDividendsMock = ImportMock . mockClass (
45
38
contractWrappersModule ,
46
39
'EtherDividendCheckpoint_3_0_0'
47
40
) ;
48
- getAttachedModulesMockStub = wrappersMock . mock (
49
- 'getModuleFactoryAddress' ,
50
- Promise . resolve ( params1 . address )
51
- ) ;
52
- tokenFactoryMockStub = tokenFactoryMock . mock (
41
+ wrappersMock . mock ( 'getModuleFactoryAddress' , Promise . resolve ( params . storageWalletAddress ) ) ;
42
+ tokenFactoryMock . mock (
53
43
'getSecurityTokenInstanceFromTicker' ,
54
44
securityTokenMock . getMockInstance ( )
55
45
) ;
56
46
57
47
// Instantiate EnableDividendManagers
58
- target = new EnableDividendManagers (
59
- {
60
- symbol : params1 . symbol ,
61
- storageWalletAddress : params1 . address ,
62
- } ,
63
- contextMock . getMockInstance ( )
64
- ) ;
48
+ target = new EnableDividendManagers ( params , contextMock . getMockInstance ( ) ) ;
65
49
} ) ;
66
50
afterEach ( ( ) => {
67
51
restore ( ) ;
@@ -75,7 +59,7 @@ describe('EnableDividendManagers', () => {
75
59
} ) ;
76
60
77
61
describe ( 'EnableDividendManagers' , ( ) => {
78
- test ( 'should send the transaction to EnableDividendManagers ' , async ( ) => {
62
+ test ( 'should add a transaction to the queue to enable dividend managers ' , async ( ) => {
79
63
const addTransactionSpy = spy ( target , 'addTransaction' ) ;
80
64
// Real call
81
65
await target . prepareTransactions ( ) ;
@@ -102,14 +86,14 @@ describe('EnableDividendManagers', () => {
102
86
tokenFactoryMock . set (
103
87
'getSecurityTokenInstanceFromTicker' ,
104
88
stub ( )
105
- . withArgs ( { address : params1 . symbol } )
89
+ . withArgs ( { address : params . symbol } )
106
90
. throws ( )
107
91
) ;
108
92
109
93
expect ( target . prepareTransactions ( ) ) . rejects . toThrow (
110
94
new PolymathError ( {
111
95
code : ErrorCode . ProcedureValidationError ,
112
- message : `There is no Security Token with symbol ${ params1 . symbol } ` ,
96
+ message : `There is no Security Token with symbol ${ params . symbol } ` ,
113
97
} )
114
98
) ;
115
99
} ) ;
0 commit comments