-
Notifications
You must be signed in to change notification settings - Fork 37
test: unit tests for get-account-info #489
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
base: main
Are you sure you want to change the base?
test: unit tests for get-account-info #489
Conversation
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.
Caution
Changes requested ❌
Reviewed everything up to 441fb6a in 2 minutes and 37 seconds. Click for details.
- Reviewed
141lines of code in1files - Skipped
0files when reviewing. - Skipped posting
1draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/solana-client/test/get-account-info.test.ts:12
- Draft comment:
Consider using lowerCamelCase (e.g. accountInfo) for plain objects instead of PascalCase (AccountInfo), which is typically reserved for classes or constructors. - Reason this comment was not posted:
Confidence changes required:33%<= threshold50%None
Workflow ID: wflow_TUCarj6A2Cfkm1eU
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
| } as unknown as SolanaClient | ||
|
|
||
| // ACT & ASSERT | ||
| expect(() => |
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.
Check if getAccountInfo throws synchronously for invalid addresses. In other tests, it returns a promise (using await). If getAccountInfo is always async, consider using await expect(...).rejects.toThrow() for consistency.
| const mockSend = vi.fn().mockResolvedValue(AccountInfo) | ||
| const mockGetAccountInfo = vi.fn().mockReturnValue({ send: mockSend }) | ||
| const mockClient = { | ||
| rpc: { | ||
| getAccountInfo: mockGetAccountInfo, | ||
| }, | ||
| } as unknown as SolanaClient |
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.
We should mock only what's needed but create the actual client https://vitest.dev/guide/mocking.html
| const result = await getAccountInfo(mockClient, { address: testAddress }) | ||
|
|
||
| // ASSERT | ||
| expect(result).toEqual(AccountInfo) |
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.
This is not very useful because you are just testing the mock. What else can we assert here?
Description
Issue #379
Screenshots / Video
Checklist
Important
Add unit tests for
getAccountInfoto cover expected and unexpected behaviors, including error handling.getAccountInfoinget-account-info.test.ts.This description was created by
for 441fb6a. You can customize this summary. It will automatically update as commits are pushed.