|
1 | 1 | /* eslint-disable import/no-duplicates */ |
2 | 2 | import { ImportMock, MockManager } from 'ts-mock-imports'; |
3 | | -import sinon, { stub, restore } from 'sinon'; |
4 | | -import { BigNumber, ModuleName } from '@polymathnetwork/contract-wrappers'; |
| 3 | +import { spy, restore } from 'sinon'; |
| 4 | +import { BigNumber } from '@polymathnetwork/contract-wrappers'; |
5 | 5 | import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; |
6 | 6 | import * as contextModule from '../../Context'; |
7 | 7 | import * as wrappersModule from '../../PolymathBase'; |
@@ -64,71 +64,43 @@ describe('EnablePercentageTransferManager', () => { |
64 | 64 |
|
65 | 65 | describe('EnablePercentageTransferManager', () => { |
66 | 66 | test('should add a transaction to the queue to enable percentage transfer manager', async () => { |
67 | | - const addModuleWithLabelArgsSpy = sinon.spy(); |
68 | | - const addTransactionStub = stub(target, 'addTransaction'); |
| 67 | + const addTransactionSpy = spy(target, 'addTransaction'); |
69 | 68 | securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); |
70 | | - const { addModuleWithLabel } = securityTokenMock.getMockInstance(); |
71 | | - addTransactionStub.withArgs(addModuleWithLabel).returns(addModuleWithLabelArgsSpy); |
72 | 69 |
|
73 | 70 | // Real call |
74 | 71 | await target.prepareTransactions(); |
75 | 72 |
|
76 | 73 | // Verifications |
77 | | - expect(addModuleWithLabelArgsSpy.getCall(0).args[0]).toEqual({ |
78 | | - moduleName: ModuleName.PercentageTransferManager, |
79 | | - address: moduleFactoryAddress, |
80 | | - archived: false, |
81 | | - data: { |
82 | | - allowPrimaryIssuance: false, |
83 | | - maxHolderPercentage: params.maxHolderPercentage, |
84 | | - }, |
85 | | - }); |
86 | | - expect(addModuleWithLabelArgsSpy.callCount).toEqual(1); |
87 | | - |
88 | 74 | expect( |
89 | | - addTransactionStub |
| 75 | + addTransactionSpy |
90 | 76 | .getCall(0) |
91 | 77 | .calledWithExactly(securityTokenMock.getMockInstance().addModuleWithLabel, { |
92 | 78 | tag: PolyTransactionTag.EnablePercentageTransferManager, |
93 | 79 | }) |
94 | 80 | ).toEqual(true); |
95 | | - expect(addTransactionStub.callCount).toEqual(1); |
| 81 | + expect(addTransactionSpy.callCount).toEqual(1); |
96 | 82 | }); |
97 | 83 |
|
98 | 84 | test('should add a transaction to the queue to enable percentage transfer manager with primary issuance', async () => { |
99 | 85 | target = new EnablePercentageTransferManager( |
100 | 86 | { ...params, allowPrimaryIssuance: true }, |
101 | 87 | contextMock.getMockInstance() |
102 | 88 | ); |
103 | | - const addModuleWithLabelArgsSpy = sinon.spy(); |
104 | | - const addTransactionStub = stub(target, 'addTransaction'); |
| 89 | + const addTransactionSpy = spy(target, 'addTransaction'); |
105 | 90 | securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); |
106 | | - const { addModuleWithLabel } = securityTokenMock.getMockInstance(); |
107 | | - addTransactionStub.withArgs(addModuleWithLabel).returns(addModuleWithLabelArgsSpy); |
108 | 91 |
|
109 | 92 | // Real call |
110 | 93 | await target.prepareTransactions(); |
111 | 94 |
|
112 | 95 | // Verifications |
113 | | - expect(addModuleWithLabelArgsSpy.getCall(0).args[0]).toEqual({ |
114 | | - moduleName: ModuleName.PercentageTransferManager, |
115 | | - address: moduleFactoryAddress, |
116 | | - archived: false, |
117 | | - data: { |
118 | | - allowPrimaryIssuance: true, |
119 | | - maxHolderPercentage: params.maxHolderPercentage, |
120 | | - }, |
121 | | - }); |
122 | | - expect(addModuleWithLabelArgsSpy.callCount).toEqual(1); |
123 | | - |
124 | 96 | expect( |
125 | | - addTransactionStub |
| 97 | + addTransactionSpy |
126 | 98 | .getCall(0) |
127 | 99 | .calledWithExactly(securityTokenMock.getMockInstance().addModuleWithLabel, { |
128 | 100 | tag: PolyTransactionTag.EnablePercentageTransferManager, |
129 | 101 | }) |
130 | 102 | ).toEqual(true); |
131 | | - expect(addTransactionStub.callCount).toEqual(1); |
| 103 | + expect(addTransactionSpy.callCount).toEqual(1); |
132 | 104 | }); |
133 | 105 |
|
134 | 106 | test('should throw if there is no valid security token supplied', async () => { |
|
0 commit comments