1
1
import { ImportMock , MockManager } from 'ts-mock-imports' ;
2
- import { spy , restore } from 'sinon' ;
2
+ import sinon , { spy , stub , restore } from 'sinon' ;
3
3
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers' ;
4
4
import * as contextModule from '../../Context' ;
5
5
import * as wrappersModule from '../../PolymathBase' ;
@@ -15,6 +15,7 @@ import {
15
15
import { PolymathError } from '../../PolymathError' ;
16
16
import { Wallet } from '../../Wallet' ;
17
17
18
+
18
19
const params : DisableControllerProcedureArgs = {
19
20
symbol : 'TEST1' ,
20
21
} ;
@@ -133,21 +134,28 @@ describe('DisableController', () => {
133
134
{ ...params , signature : randomSignature } ,
134
135
contextMock . getMockInstance ( )
135
136
) ;
136
- const addTransactionSpy = spy ( target , 'addTransaction' ) ;
137
+ const disableControllerArgsSpy = sinon . spy ( ) ;
138
+ const addTransactionStub = stub ( target , 'addTransaction' ) ;
137
139
securityTokenMock . mock ( 'disableController' , 'DisableController' ) ;
140
+ const { disableController } = securityTokenMock . getMockInstance ( ) ;
141
+ addTransactionStub . withArgs ( disableController ) . returns ( disableControllerArgsSpy ) ;
138
142
139
143
// Real call
140
144
await target . prepareTransactions ( ) ;
141
145
142
146
// Verifications
147
+ expect ( disableControllerArgsSpy . getCall ( 0 ) . args [ 0 ] ) . toEqual ( {
148
+ signature : randomSignature ,
149
+ } ) ;
150
+ expect ( disableControllerArgsSpy . callCount ) . toEqual ( 1 ) ;
143
151
expect (
144
- addTransactionSpy
152
+ addTransactionStub
145
153
. getCall ( 0 )
146
154
. calledWithExactly ( securityTokenMock . getMockInstance ( ) . disableController , {
147
155
tag : PolyTransactionTag . DisableController ,
148
156
} )
149
157
) . toEqual ( true ) ;
150
- expect ( addTransactionSpy . callCount ) . toEqual ( 1 ) ;
158
+ expect ( addTransactionStub . callCount ) . toEqual ( 1 ) ;
151
159
} ) ;
152
160
} ) ;
153
161
} ) ;
0 commit comments