@@ -2,10 +2,10 @@ import * as sinon from 'sinon';
22import { ImportMock , MockManager } from 'ts-mock-imports' ;
33import BigNumber from 'bignumber.js' ;
44import * as contractWrappersObject from '@polymathnetwork/contract-wrappers' ;
5+ import { SinonStub } from 'sinon' ;
56import * as contextObject from '../../Context' ;
67import * as wrappersObject from '../../PolymathBase' ;
78import { CreateSecurityToken } from '../../procedures/CreateSecurityToken' ;
8- // import * as approveErc20Object from '../../procedures/ApproveErc20';
99import { Procedure } from '~/procedures/Procedure' ;
1010import { Wallet } from '~/Wallet' ;
1111
@@ -22,15 +22,18 @@ describe('CreateSecurityToken', () => {
2222 let target : CreateSecurityToken ;
2323 let contextMock : MockManager < contextObject . Context > ;
2424 let wrappersMock : MockManager < wrappersObject . PolymathBase > ;
25- // let approveErc20Mock: MockManager<approveErc20Object.ApproveErc20>;
25+ let polyTokenMock : MockManager < contractWrappersObject . PolyToken > ;
26+ let checkPolyBalanceStub : SinonStub < any , any > ;
27+ let checkPolyAddressStub : SinonStub < any , any > ;
28+ let checkPolyAllowanceStub : SinonStub < any , any > ;
2629
2730 let securityTokenRegistryMock : MockManager < contractWrappersObject . SecurityTokenRegistry > ;
2831
2932 beforeAll ( ( ) => {
3033 // Mock the context, wrappers, and tokenFactory to test
3134 contextMock = ImportMock . mockClass ( contextObject , 'Context' ) ;
3235 wrappersMock = ImportMock . mockClass ( wrappersObject , 'PolymathBase' ) ;
33- // approveErc20Mock = ImportMock.mockClass(approveErc20Object , 'ApproveErc20 ');
36+ polyTokenMock = ImportMock . mockClass ( contractWrappersObject , 'PolyToken ' ) ;
3437
3538 securityTokenRegistryMock = ImportMock . mockClass (
3639 contractWrappersObject ,
@@ -56,6 +59,15 @@ describe('CreateSecurityToken', () => {
5659 } ) ;
5760 contextMock . set ( 'currentWallet' , new Wallet ( { address : ( ) => ownerPromise } ) ) ;
5861
62+ // TODO We should replace this with a mock of ApproveErc20 but right now there is a bug
63+ // Bug with import mockClass("TypeError: Invalid attempt to spread non-iterable instance")
64+ checkPolyBalanceStub = polyTokenMock . mock ( 'balanceOf' , Promise . resolve ( new BigNumber ( 2 ) ) ) ;
65+ checkPolyAddressStub = polyTokenMock . mock ( 'address' , Promise . resolve ( params1 . owner ) ) ;
66+ checkPolyAllowanceStub = polyTokenMock . mock ( 'allowance' , Promise . resolve ( new BigNumber ( 0 ) ) ) ;
67+
68+ wrappersMock . set ( 'polyToken' , polyTokenMock . getMockInstance ( ) ) ;
69+ wrappersMock . mock ( 'isTestnet' , Promise . resolve ( false ) ) ;
70+
5971 // Instantiate CreateSecurityToken
6072 target = new CreateSecurityToken (
6173 {
0 commit comments