Conversation
staa99
reviewed
Jan 28, 2025
staa99
reviewed
Jan 28, 2025
Comment on lines
+20
to
+40
| context = { | ||
| isDbContext: true as boolean, | ||
| entrypoint: 'test', | ||
| logger: createLogger({ context: 'test' }) as BonadocsLogger, | ||
|
|
||
| // Mock query method | ||
| query: jest.fn().mockImplementation(() => | ||
| Promise.resolve({ | ||
| rowCount: 0, | ||
| rows: [], | ||
| oid: 0, | ||
| fields: [], | ||
| command: '', | ||
| } as QueryResult), | ||
| ), | ||
|
|
||
| // Mock transaction methods | ||
| beginTransaction: jest.fn().mockImplementation(() => Promise.resolve()), | ||
| commitTransaction: jest.fn().mockImplementation(() => Promise.resolve()), | ||
| rollbackTransaction: jest.fn().mockImplementation(() => Promise.resolve()), | ||
| } as unknown as DbContext; |
Contributor
There was a problem hiding this comment.
Create a test utility function to provide a mock DbContext
staa99
reviewed
Jan 28, 2025
src/modules/repositories/evm-contracts/evm-contracts.repository.test.ts
Outdated
Show resolved
Hide resolved
staa99
reviewed
Jan 28, 2025
src/modules/repositories/evm-contracts/evm-contracts.repository.test.ts
Outdated
Show resolved
Hide resolved
staa99
reviewed
Jan 28, 2025
|
|
||
| describe('getContractAbiHash', () => { | ||
| it('should return null if no contract is found', async () => { | ||
| (context.query as jest.Mock).mockImplementation(() => |
Contributor
There was a problem hiding this comment.
if you use jest.Mocked from above, this cast is unnecessary
Contributor
There was a problem hiding this comment.
Make the update across all of your test functions
staa99
reviewed
Jan 28, 2025
| describe('getContractAbiHash', () => { | ||
| it('should return null if no contract is found', async () => { | ||
| (context.query as jest.Mock).mockImplementation(() => | ||
| Promise.resolve({ |
Contributor
There was a problem hiding this comment.
Use mockResolvedValue rather than mockImplementation. It's a utility to achieve the same thing but it's neater.
staa99
reviewed
Feb 9, 2025
staa99
reviewed
Feb 9, 2025
src/modules/repositories/evm-contracts/evm-contracts.repository.ts
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Title
Description
Summary
Worked on database connection, user repository with test cases, project repository with test cases
Motivation
Explain the reason for these changes. Why is it needed? What problem does it solve?
Related Issue(s)
Detailed Changes
Checklist
Code Quality
Testing
<< Provide screenshots that show the test coverage after your PR >>
Security
Documentation
Dependencies
Deployment
Reviewer Selection
Branch Deletion
Reviewer Notes
General Review
Final Approval