Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 6cad10f

Browse files
author
Victor Wiebe
committed
feat: 🎸 volumeRestrictionTM comments refactoring and test
1 parent 034a17d commit 6cad10f

File tree

2 files changed

+240
-13
lines changed

2 files changed

+240
-13
lines changed

‎src/contract_wrappers/modules/transfer_manager/__tests__/volume_restriction_transfer_manager_wrapper.test.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,6 +2120,20 @@ describe('VolumeRestrictionTransferManagerWrapper', () => {
21202120

21212121
describe('Get Total Traded By User', () => {
21222122
test('Should getTotalTradedByUser', async () => {
2123+
// Security Token Address expected
2124+
const expectedSecurityTokenAddress = '0x3333333333333333333333333333333333333333';
2125+
// Setup get Security Token Address
2126+
const mockedGetSecurityTokenAddressMethod = mock(MockedCallMethod);
2127+
when(mockedContract.securityToken).thenReturn(instance(mockedGetSecurityTokenAddressMethod));
2128+
when(mockedGetSecurityTokenAddressMethod.callAsync()).thenResolve(expectedSecurityTokenAddress);
2129+
when(mockedContractFactory.getSecurityTokenContract(expectedSecurityTokenAddress)).thenResolve(
2130+
instance(mockedSecurityTokenContract),
2131+
);
2132+
const expectedDecimalsResult = new BigNumber(18);
2133+
const mockedSecurityTokenDecimalsMethod = mock(MockedCallMethod);
2134+
when(mockedSecurityTokenDecimalsMethod.callAsync()).thenResolve(expectedDecimalsResult);
2135+
when(mockedSecurityTokenContract.decimals).thenReturn(instance(mockedSecurityTokenDecimalsMethod));
2136+
21232137
// Address expected
21242138
const expectedResult = new BigNumber(100);
21252139
const mockedParams = {
@@ -2138,10 +2152,16 @@ describe('VolumeRestrictionTransferManagerWrapper', () => {
21382152
// Real call
21392153
const result = await target.getTotalTradedByUser(mockedParams);
21402154
// Result expectation
2141-
expect(result).toBe(expectedResult);
2155+
expect(result).toEqual(weiToValue(expectedResult, expectedDecimalsResult));
21422156
// Verifications
21432157
verify(mockedContract.getTotalTradedByUser).once();
21442158
verify(mockedMethod.callAsync(mockedParams.user, objectContaining(dateToBigNumber(mockedParams.at)))).once();
2159+
2160+
verify(mockedContract.securityToken).once();
2161+
verify(mockedGetSecurityTokenAddressMethod.callAsync()).once();
2162+
verify(mockedContractFactory.getSecurityTokenContract(expectedSecurityTokenAddress)).once();
2163+
verify(mockedSecurityTokenDecimalsMethod.callAsync()).once();
2164+
verify(mockedSecurityTokenContract.decimals).once();
21452165
});
21462166
});
21472167

0 commit comments

Comments
 (0)