Skip to content

Commit 2bd3d73

Browse files
author
Victor Wiebe
committed
fix: enable count transfer manager refactor
1 parent 8b9860b commit 2bd3d73

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/procedures/__tests__/EnableCountTransferManager.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ImportMock, MockManager } from 'ts-mock-imports';
2-
import { spy, restore } from 'sinon';
2+
import sinon, { stub, restore } from 'sinon';
33
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers';
4+
import { ModuleName } from '@polymathnetwork/contract-wrappers';
45
import * as contextModule from '../../Context';
56
import * as wrappersModule from '../../PolymathBase';
67
import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule';
@@ -14,6 +15,7 @@ import {
1415
ProcedureType,
1516
} from '../../types';
1617

18+
1719
const params: EnableCountTransferManagerProcedureArgs = {
1820
symbol: 'TEST1',
1921
maxHolderCount: 3,
@@ -62,21 +64,35 @@ describe('EnableCountTransferManager', () => {
6264

6365
describe('EnableCountTransferManager', () => {
6466
test('should add a transaction to the queue to enable count transfer manager', async () => {
65-
const addTransactionSpy = spy(target, 'addTransaction');
67+
const addModuleWithLabelArgsSpy = sinon.spy();
68+
const addTransactionStub = stub(target, 'addTransaction');
69+
6670
securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel'));
71+
const { addModuleWithLabel } = securityTokenMock.getMockInstance();
72+
addTransactionStub.withArgs(addModuleWithLabel).returns(addModuleWithLabelArgsSpy);
6773

6874
// Real call
6975
await target.prepareTransactions();
7076

7177
// Verifications
78+
expect(addModuleWithLabelArgsSpy.getCall(0).args[0]).toEqual({
79+
moduleName: ModuleName.CountTransferManager,
80+
address: moduleFactoryAddress,
81+
archived: false,
82+
data: {
83+
maxHolderCount: params.maxHolderCount,
84+
},
85+
});
86+
expect(addModuleWithLabelArgsSpy.callCount).toEqual(1);
87+
7288
expect(
73-
addTransactionSpy
89+
addTransactionStub
7490
.getCall(0)
7591
.calledWithExactly(securityTokenMock.getMockInstance().addModuleWithLabel, {
7692
tag: PolyTransactionTag.EnableCountTransferManager,
7793
})
7894
).toEqual(true);
79-
expect(addTransactionSpy.callCount).toEqual(1);
95+
expect(addTransactionStub.callCount).toEqual(1);
8096
});
8197

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

0 commit comments

Comments
 (0)