Skip to content

Commit

Permalink
fix: createSecurity token, now passes but does not mock approveErc20
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Wiebe committed Oct 9, 2019
1 parent 1e203eb commit 462a856
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/procedures/__tests__/CreateSecurityToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import * as sinon from 'sinon';
import { ImportMock, MockManager } from 'ts-mock-imports';
import BigNumber from 'bignumber.js';
import * as contractWrappersObject from '@polymathnetwork/contract-wrappers';
import { SinonStub } from 'sinon';
import * as contextObject from '../../Context';
import * as wrappersObject from '../../PolymathBase';
import { CreateSecurityToken } from '../../procedures/CreateSecurityToken';
// import * as approveErc20Object from '../../procedures/ApproveErc20';
import { Procedure } from '~/procedures/Procedure';
import { Wallet } from '~/Wallet';

Expand All @@ -22,15 +22,18 @@ describe('CreateSecurityToken', () => {
let target: CreateSecurityToken;
let contextMock: MockManager<contextObject.Context>;
let wrappersMock: MockManager<wrappersObject.PolymathBase>;
// let approveErc20Mock: MockManager<approveErc20Object.ApproveErc20>;
let polyTokenMock: MockManager<contractWrappersObject.PolyToken>;
let checkPolyBalanceStub: SinonStub<any, any>;
let checkPolyAddressStub: SinonStub<any, any>;
let checkPolyAllowanceStub: SinonStub<any, any>;

let securityTokenRegistryMock: MockManager<contractWrappersObject.SecurityTokenRegistry>;

beforeAll(() => {
// Mock the context, wrappers, and tokenFactory to test
contextMock = ImportMock.mockClass(contextObject, 'Context');
wrappersMock = ImportMock.mockClass(wrappersObject, 'PolymathBase');
// approveErc20Mock = ImportMock.mockClass(approveErc20Object, 'ApproveErc20');
polyTokenMock = ImportMock.mockClass(contractWrappersObject, 'PolyToken');

securityTokenRegistryMock = ImportMock.mockClass(
contractWrappersObject,
Expand All @@ -56,6 +59,15 @@ describe('CreateSecurityToken', () => {
});
contextMock.set('currentWallet', new Wallet({ address: () => ownerPromise }));

// TODO We should replace this with a mock of ApproveErc20 but right now there is a bug
// Bug with import mockClass("TypeError: Invalid attempt to spread non-iterable instance")
checkPolyBalanceStub = polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(2)));
checkPolyAddressStub = polyTokenMock.mock('address', Promise.resolve(params1.owner));
checkPolyAllowanceStub = polyTokenMock.mock('allowance', Promise.resolve(new BigNumber(0)));

wrappersMock.set('polyToken', polyTokenMock.getMockInstance());
wrappersMock.mock('isTestnet', Promise.resolve(false));

// Instantiate CreateSecurityToken
target = new CreateSecurityToken(
{
Expand Down

0 comments on commit 462a856

Please sign in to comment.