Skip to content

Commit 2b9f892

Browse files
committed
test: restore coverage lost to strict-null-check test removals
Several not-found/no-op branches (getTransactionForCreator, SignersService.getSignatureById, UserKeysService.removeKey) lost their tests when strict null checks made the old null-argument mocks stop compiling; re-added equivalent tests using valid inputs (empty result, falsy id, null resolve) instead of the now-illegal null args. Signed-off-by: John Bair <john.bair@swirldslabs.com>
1 parent 161c371 commit 2b9f892

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

back-end/apps/api/src/transactions/signers/signers.service.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ describe('SignersService', () => {
138138
withDeleted: true,
139139
});
140140
});
141+
142+
it('should return null if id not provided', async () => {
143+
const result = await service.getSignatureById(0);
144+
145+
expect(result).toBeNull();
146+
});
141147
});
142148

143149
describe('getSignaturesByUser', () => {

back-end/apps/api/src/transactions/transactions.service.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,14 @@ describe('TransactionsService', () => {
31813181
jest.resetAllMocks();
31823182
});
31833183

3184+
it('should throw TNF if no transaction is found', async () => {
3185+
transactionsRepo.find.mockResolvedValueOnce([]);
3186+
3187+
await expect(service.getTransactionForCreator(1, user as User)).rejects.toThrow(
3188+
ErrorCodes.TNF,
3189+
);
3190+
});
3191+
31843192
it('should throw if user is not the creator', async () => {
31853193
const transaction = { creatorKey: { userId: 231232 } };
31863194

back-end/apps/api/src/user-keys/user-keys.service.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ describe('UserKeysService', () => {
255255
});
256256

257257
describe('removeKey', () => {
258+
it('should throw BadRequestException if the key does not exist', async () => {
259+
repo.findOne.mockResolvedValue(null);
260+
261+
await expect(service.removeKey(1)).rejects.toThrow(ErrorCodes.KNF);
262+
});
263+
258264
it('should soft remove the user key if it exists', async () => {
259265
const userKey = { id: 1, publicKey: 'test-public-key' } as UserKey;
260266
repo.findOne.mockResolvedValue(userKey);

0 commit comments

Comments
 (0)