-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add unit tests for account.ts #176
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
||
// Verify | ||
expect(db.get).toHaveBeenCalledTimes(1) | ||
expect(result).toBeUndefined() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Ensure that the test case for a non-existent account returns null
instead of undefined
to maintain consistency with the function's expected behavior. [possible issue, importance: 8]
expect(result).toBeUndefined() | |
expect(result).toBeNull() |
// Verify | ||
expect(db.all).not.toHaveBeenCalled() | ||
expect(Logger.mainLogger.error).toHaveBeenCalledWith('queryAccounts - Invalid skip or limit value') | ||
expect(result).toEqual([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Verify that the test case for invalid skip or limit values returns null
instead of an empty array to align with the function's expected behavior. [possible issue, importance: 8]
expect(result).toEqual([]) | |
expect(result).toBeNull() |
// Verify | ||
expect(db.all).toHaveBeenCalledTimes(1) | ||
expect(Logger.mainLogger.error).toHaveBeenCalledWith(error) | ||
expect(result).toEqual([]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: Ensure that the test case for a failed query returns null
instead of an empty array to match the function's expected behavior. [possible issue, importance: 8]
expect(result).toEqual([]) | |
expect(result).toBeNull() |
PR Type
Tests
Description
Add comprehensive unit tests for
accounts
module.Mock dependencies for isolated testing.
Validate database operations and error handling.
Ensure logging behavior under different configurations.
Changes walkthrough 📝
accounts.test.ts
Add unit tests for account operations with mocks
test/unit/src/dbstore/accounts.test.ts