Skip to content

Commit b5aa85e

Browse files
author
Victor Wiebe
committed
fix: use the correct method of verification
1 parent a3936e3 commit b5aa85e

File tree

5 files changed

+57
-41
lines changed

5 files changed

+57
-41
lines changed

src/procedures/__tests__/ControllerTransfer.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,13 @@ describe('ControllerTransfer', () => {
7878
await target.prepareTransactions();
7979

8080
// Verifications
81+
8182
expect(
82-
addTransactionSpy.withArgs(securityTokenMock.getMockInstance().controllerTransfer).callCount
83-
).toBe(1);
83+
addTransactionSpy
84+
.getCall(0)
85+
.calledWith(securityTokenMock.getMockInstance().controllerTransfer)
86+
).toEqual(true);
87+
expect(addTransactionSpy.callCount).toEqual(1);
8488
});
8589

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

src/procedures/__tests__/CreateCheckpoint.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ describe('CreateCheckpoint', () => {
5050
contextMock.set('contractWrappers', wrappersMock.getMockInstance());
5151
wrappersMock.set('tokenFactory', tokenFactoryMock.getMockInstance());
5252

53-
checkpointFactoryMock = ImportMock.mockClass(
54-
checkpointFactoryModule,
55-
'CheckpointFactory'
56-
);
53+
checkpointFactoryMock = ImportMock.mockClass(checkpointFactoryModule, 'CheckpointFactory');
5754
const factoryMockSetup = mockFactories();
5855
factoryMockSetup.checkpointFactory = checkpointFactoryMock.getMockInstance();
5956
contextMock.set('factories', factoryMockSetup);
@@ -85,8 +82,11 @@ describe('CreateCheckpoint', () => {
8582
await target.prepareTransactions();
8683
// Verifications
8784
expect(
88-
addTransactionSpy.withArgs(securityTokenMock.getMockInstance().controllerTransfer).callCount
89-
).toBe(1);
85+
addTransactionSpy
86+
.getCall(0)
87+
.calledWith(securityTokenMock.getMockInstance().controllerTransfer)
88+
).toEqual(true);
89+
expect(addTransactionSpy.callCount).toEqual(1);
9090
});
9191

9292
test('should throw if corresponding checkpoint event is not fired', async () => {

src/procedures/__tests__/CreateErc20DividendDistribution.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,16 @@ describe('CreateErc20DividendDistribution', () => {
113113
await target.prepareTransactions();
114114

115115
// Verifications
116+
expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true);
116117
expect(
117-
addTransactionSpy.withArgs(erc20DividendsMock.getMockInstance().setWithholding).callCount
118-
).toBe(1);
119-
expect(
120-
addTransactionSpy.withArgs(
121-
erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
122-
).callCount
123-
).toBe(1);
124-
expect(addProcedureSpy.withArgs(ApproveErc20).callCount).toBe(1);
118+
addTransactionSpy
119+
.getCall(0)
120+
.calledWith(
121+
erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
122+
)
123+
).toEqual(true);
124+
expect(addTransactionSpy.callCount).toEqual(1);
125+
expect(addProcedureSpy.callCount).toEqual(1);
125126
});
126127

127128
test('should send the transaction to CreateErc20DividendDistribution with taxWitholdings', async () => {
@@ -149,15 +150,19 @@ describe('CreateErc20DividendDistribution', () => {
149150
await target.prepareTransactions();
150151

151152
// Verifications
153+
expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true);
152154
expect(
153-
addTransactionSpy.withArgs(erc20DividendsMock.getMockInstance().setWithholding).callCount
154-
).toBe(2);
155+
addTransactionSpy
156+
.getCall(0)
157+
.calledWith(
158+
erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
159+
)
160+
).toEqual(true);
155161
expect(
156-
addTransactionSpy.withArgs(
157-
erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
158-
).callCount
159-
).toBe(2);
160-
expect(addProcedureSpy.withArgs(ApproveErc20).callCount).toBe(1);
162+
addTransactionSpy.getCall(1).calledWith(erc20DividendsMock.getMockInstance().setWithholding)
163+
).toEqual(true);
164+
expect(addTransactionSpy.callCount).toEqual(2);
165+
expect(addProcedureSpy.callCount).toEqual(1);
161166
});
162167

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

src/procedures/__tests__/CreateEtherDividendDistribution.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as contextModule from '../../Context';
1414
import * as wrappersModule from '../../PolymathBase';
1515
import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryObject';
1616
import { mockFactories } from '~/testUtils/MockFactories';
17+
import { ApproveErc20 } from '~/procedures';
1718

1819
const params1 = {
1920
symbol: 'TEST1',
@@ -98,13 +99,13 @@ describe('CreateEtherDividendDistribution', () => {
9899

99100
// Verifications
100101
expect(
101-
addTransactionSpy.withArgs(etherDividendsMock.getMockInstance().setWithholding).callCount
102-
).toBe(1);
103-
expect(
104-
addTransactionSpy.withArgs(
105-
etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
106-
).callCount
107-
).toBe(1);
102+
addTransactionSpy
103+
.getCall(0)
104+
.calledWith(
105+
etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
106+
)
107+
).toEqual(true);
108+
expect(addTransactionSpy.callCount).toEqual(1);
108109
});
109110

110111
test('should send the transaction to CreateEtherDividendDistribution with taxwithholdings', async () => {
@@ -132,13 +133,16 @@ describe('CreateEtherDividendDistribution', () => {
132133

133134
// Verifications
134135
expect(
135-
addTransactionSpy.withArgs(etherDividendsMock.getMockInstance().setWithholding).callCount
136-
).toBe(2);
136+
addTransactionSpy
137+
.getCall(0)
138+
.calledWith(
139+
etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
140+
)
141+
).toEqual(true);
137142
expect(
138-
addTransactionSpy.withArgs(
139-
etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions
140-
).callCount
141-
).toBe(2);
143+
addTransactionSpy.getCall(1).calledWith(etherDividendsMock.getMockInstance().setWithholding)
144+
).toEqual(true);
145+
expect(addTransactionSpy.callCount).toEqual(2);
142146
});
143147

144148
test('should throw if corresponding event is not fired', async () => {

src/procedures/__tests__/CreateSecurityToken.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,14 @@ describe('CreateSecurityToken', () => {
192192

193193
// Verifications
194194
expect(
195-
addTransactionSpy.withArgs(
196-
securityTokenRegistryMock.getMockInstance().generateNewSecurityToken
197-
).callCount
198-
).toBe(1);
199-
expect(addProcedureSpy.withArgs(ApproveErc20).callCount).toBe(1);
195+
addTransactionSpy
196+
.getCall(0)
197+
.calledWith(securityTokenRegistryMock.getMockInstance().generateNewSecurityToken)
198+
).toEqual(true);
199+
200+
expect(addTransactionSpy.callCount).toEqual(1);
201+
expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true);
202+
expect(addProcedureSpy.callCount).toEqual(1);
200203
});
201204

202205
test('should send the transaction to CreateSecurityToken with a treasury wallet', async () => {

0 commit comments

Comments
 (0)