Skip to content

Commit 2dabfc6

Browse files
author
Victor Wiebe
committed
feat: continue improving modify shareholder data
some tests are not resulting well
1 parent cacaeb2 commit 2dabfc6

File tree

1 file changed

+46
-21
lines changed

1 file changed

+46
-21
lines changed

src/procedures/__tests__/ModifyShareholderData.ts

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ describe('ModifyShareholderData', () => {
8181
{
8282
address: testAddress,
8383
canSendAfter: new Date(Date.now()),
84-
canReceiveAfter: new Date(0, 0),
84+
canReceiveAfter: new Date(1980, 1),
8585
kycExpiry: new Date(2035, 1),
8686
canBuyFromSto: true,
8787
isAccredited: true,
8888
},
8989
{
9090
address: testAddress2,
9191
canSendAfter: new Date(Date.now()),
92-
canReceiveAfter: new Date(0, 0),
92+
canReceiveAfter: new Date(1980, 1),
9393
kycExpiry: new Date(2035, 1),
9494
canBuyFromSto: true,
9595
isAccredited: true,
@@ -144,25 +144,7 @@ describe('ModifyShareholderData', () => {
144144
).toEqual(true);
145145
expect(addTransactionSpy.callCount).toEqual(2);
146146
});
147-
// TODO
148-
/*
149-
test('should throw if corresponding checkpoint event is not fired', async () => {
150-
ImportMock.mockFunction(utilsModule, 'findEvents', []);
151-
152-
// Real call
153-
const resolver = await target.prepareTransactions();
154147

155-
await expect(
156-
resolver.run({} as TransactionReceiptWithDecodedLogs)
157-
).rejects.toThrow(
158-
new PolymathError({
159-
code: ErrorCode.UnexpectedEventLogs,
160-
message:
161-
"The Checkpoint was successfully created but the corresponding event wasn't fired. Please report this issue to the Polymath team.",
162-
})
163-
);
164-
});
165-
*/
166148
test('should return the newly created checkpoint', async () => {
167149
const shareholderObject = {
168150
shareholder: {
@@ -180,7 +162,9 @@ describe('ModifyShareholderData', () => {
180162
expect(
181163
fetchStub.getCall(0).calledWithExactly(
182164
Shareholder.generateId({
183-
securityTokenId: SecurityToken.generateId({ symbol: params.symbol }),
165+
securityTokenId: SecurityToken.generateId({
166+
symbol: params.symbol,
167+
}),
184168
address: params.shareholderData[0].address,
185169
})
186170
)
@@ -202,5 +186,46 @@ describe('ModifyShareholderData', () => {
202186
})
203187
);
204188
});
189+
/*
190+
test('should throw if there is an invalid epoch time', async () => {
191+
const invalidParams = params;
192+
invalidParams.shareholderData = [{
193+
canReceiveAfter: new Date(1970,0),
194+
canSendAfter: new Date(1970,0),
195+
address: testAddress,
196+
canBuyFromSto: true,
197+
isAccredited: true,
198+
kycExpiry: new Date(0, 0)
199+
}];
200+
target = new ModifyShareholderData(invalidParams, contextMock.getMockInstance());
201+
await expect(target.prepareTransactions()).rejects.toThrow(
202+
new PolymathError({
203+
code: ErrorCode.ProcedureValidationError,
204+
message:
205+
"Cannot set dates to epoch. If you're trying to revoke a shareholder's KYC, use .revokeKyc()",
206+
})
207+
);
208+
});
209+
210+
test('should throw if modifying share holder fails', async () => {
211+
await expect(target.prepareTransactions()).rejects.toThrow(
212+
new PolymathError({
213+
code: ErrorCode.ProcedureValidationError,
214+
message: 'Modify shareholder data failed: Nothing to modify',
215+
})
216+
);
217+
});
218+
*/
219+
test('should throw if the general transfer manager is not enabled', async () => {
220+
wrappersMock.mock('getAttachedModules', {});
221+
await expect(target.prepareTransactions()).rejects.toThrow(
222+
new PolymathError({
223+
code: ErrorCode.ProcedureValidationError,
224+
message: `General Transfer Manager for token "${
225+
params.symbol
226+
}" isn't enabled. Please report this issue to the Polymath team`,
227+
})
228+
);
229+
});
205230
});
206231
});

0 commit comments

Comments
 (0)