Skip to content

Commit 1ccae8d

Browse files
author
Victor Wiebe
committed
refactor: disable controller one working test
1 parent a91931f commit 1ccae8d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/procedures/__tests__/DisableController.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ImportMock, MockManager } from 'ts-mock-imports';
2-
import { spy, restore } from 'sinon';
2+
import sinon, { spy, stub, restore } from 'sinon';
33
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers';
44
import * as contextModule from '../../Context';
55
import * as wrappersModule from '../../PolymathBase';
@@ -15,6 +15,7 @@ import {
1515
import { PolymathError } from '../../PolymathError';
1616
import { Wallet } from '../../Wallet';
1717

18+
1819
const params: DisableControllerProcedureArgs = {
1920
symbol: 'TEST1',
2021
};
@@ -133,21 +134,28 @@ describe('DisableController', () => {
133134
{ ...params, signature: randomSignature },
134135
contextMock.getMockInstance()
135136
);
136-
const addTransactionSpy = spy(target, 'addTransaction');
137+
const disableControllerArgsSpy = sinon.spy();
138+
const addTransactionStub = stub(target, 'addTransaction');
137139
securityTokenMock.mock('disableController', 'DisableController');
140+
const { disableController } = securityTokenMock.getMockInstance();
141+
addTransactionStub.withArgs(disableController).returns(disableControllerArgsSpy);
138142

139143
// Real call
140144
await target.prepareTransactions();
141145

142146
// Verifications
147+
expect(disableControllerArgsSpy.getCall(0).args[0]).toEqual({
148+
signature: randomSignature,
149+
});
150+
expect(disableControllerArgsSpy.callCount).toEqual(1);
143151
expect(
144-
addTransactionSpy
152+
addTransactionStub
145153
.getCall(0)
146154
.calledWithExactly(securityTokenMock.getMockInstance().disableController, {
147155
tag: PolyTransactionTag.DisableController,
148156
})
149157
).toEqual(true);
150-
expect(addTransactionSpy.callCount).toEqual(1);
158+
expect(addTransactionStub.callCount).toEqual(1);
151159
});
152160
});
153161
});

0 commit comments

Comments
 (0)