Skip to content

Commit

Permalink
fix: remove the changes made to ptm, prevent conflict with other pr
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Wiebe committed Feb 7, 2020
1 parent 2d50f1d commit f86a6a8
Showing 1 changed file with 8 additions and 36 deletions.
44 changes: 8 additions & 36 deletions src/procedures/__tests__/EnablePercentageTransferManager.ts
@@ -1,7 +1,7 @@
/* eslint-disable import/no-duplicates */
import { ImportMock, MockManager } from 'ts-mock-imports';
import sinon, { stub, restore } from 'sinon';
import { BigNumber, ModuleName } from '@polymathnetwork/contract-wrappers';
import { spy, restore } from 'sinon';
import { BigNumber } from '@polymathnetwork/contract-wrappers';
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers';
import * as contextModule from '../../Context';
import * as wrappersModule from '../../PolymathBase';
Expand Down Expand Up @@ -64,71 +64,43 @@ describe('EnablePercentageTransferManager', () => {

describe('EnablePercentageTransferManager', () => {
test('should add a transaction to the queue to enable percentage transfer manager', async () => {
const addModuleWithLabelArgsSpy = sinon.spy();
const addTransactionStub = stub(target, 'addTransaction');
const addTransactionSpy = spy(target, 'addTransaction');
securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel'));
const { addModuleWithLabel } = securityTokenMock.getMockInstance();
addTransactionStub.withArgs(addModuleWithLabel).returns(addModuleWithLabelArgsSpy);

// Real call
await target.prepareTransactions();

// Verifications
expect(addModuleWithLabelArgsSpy.getCall(0).args[0]).toEqual({
moduleName: ModuleName.PercentageTransferManager,
address: moduleFactoryAddress,
archived: false,
data: {
allowPrimaryIssuance: false,
maxHolderPercentage: params.maxHolderPercentage,
},
});
expect(addModuleWithLabelArgsSpy.callCount).toEqual(1);

expect(
addTransactionStub
addTransactionSpy
.getCall(0)
.calledWithExactly(securityTokenMock.getMockInstance().addModuleWithLabel, {
tag: PolyTransactionTag.EnablePercentageTransferManager,
})
).toEqual(true);
expect(addTransactionStub.callCount).toEqual(1);
expect(addTransactionSpy.callCount).toEqual(1);
});

test('should add a transaction to the queue to enable percentage transfer manager with primary issuance', async () => {
target = new EnablePercentageTransferManager(
{ ...params, allowPrimaryIssuance: true },
contextMock.getMockInstance()
);
const addModuleWithLabelArgsSpy = sinon.spy();
const addTransactionStub = stub(target, 'addTransaction');
const addTransactionSpy = spy(target, 'addTransaction');
securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel'));
const { addModuleWithLabel } = securityTokenMock.getMockInstance();
addTransactionStub.withArgs(addModuleWithLabel).returns(addModuleWithLabelArgsSpy);

// Real call
await target.prepareTransactions();

// Verifications
expect(addModuleWithLabelArgsSpy.getCall(0).args[0]).toEqual({
moduleName: ModuleName.PercentageTransferManager,
address: moduleFactoryAddress,
archived: false,
data: {
allowPrimaryIssuance: true,
maxHolderPercentage: params.maxHolderPercentage,
},
});
expect(addModuleWithLabelArgsSpy.callCount).toEqual(1);

expect(
addTransactionStub
addTransactionSpy
.getCall(0)
.calledWithExactly(securityTokenMock.getMockInstance().addModuleWithLabel, {
tag: PolyTransactionTag.EnablePercentageTransferManager,
})
).toEqual(true);
expect(addTransactionStub.callCount).toEqual(1);
expect(addTransactionSpy.callCount).toEqual(1);
});

test('should throw if there is no valid security token supplied', async () => {
Expand Down

0 comments on commit f86a6a8

Please sign in to comment.