-
Notifications
You must be signed in to change notification settings - Fork 272
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
feat: keep polishing onStatus lifecycle #1055
Merged
+163
−126
Merged
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8087aad
feat: keep polishing onStatus lifecycle
Zizzamia 61176d1
ok
Zizzamia 42abe37
dope
Zizzamia d2a8dee
ok
Zizzamia 9cbcf8c
ok
Zizzamia 8532b4f
dope
Zizzamia b77cf96
ok
Zizzamia a1ec415
ok
Zizzamia 08ac841
ok
Zizzamia 612cccc
ok
Zizzamia 54f1680
ok
Zizzamia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
dope
commit 42abe375906b81aacaa79e4f5c4293d450b92e43
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,18 +133,18 @@ describe('TransactionProvider', () => { | |
}); | ||
}); | ||
|
||
it('should call onsuccess when receipt exists', async () => { | ||
it('should call onSuccess when one receipt exist', async () => { | ||
const onSuccessMock = vi.fn(); | ||
(useWaitForTransactionReceipt as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
data: '123', | ||
data: { status: 'success' }, | ||
}); | ||
(useCallsStatus as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
transactionHash: 'hash', | ||
}); | ||
render( | ||
<TransactionProvider | ||
address="0x123" | ||
contracts={[]} | ||
contracts={[{ address: '0x123', method: 'method' }]} | ||
onSuccess={onSuccessMock} | ||
> | ||
<TestComponent /> | ||
|
@@ -154,9 +154,16 @@ describe('TransactionProvider', () => { | |
fireEvent.click(button); | ||
await waitFor(() => { | ||
expect(onSuccessMock).toHaveBeenCalled(); | ||
expect(onSuccessMock).toHaveBeenCalledWith({ | ||
transactionReceipts: [{ status: 'success' }], | ||
}); | ||
}); | ||
}); | ||
|
||
it('should call onSuccess when many receipts are available', async () => { | ||
// todo: implement test | ||
}); | ||
|
||
it('should handle errors during submission', async () => { | ||
const writeContractsAsyncMock = vi | ||
.fn() | ||
|
@@ -252,30 +259,6 @@ describe('TransactionProvider', () => { | |
}); | ||
}); | ||
|
||
it('should call onSuccess when receipts are available', async () => { | ||
const onSuccessMock = vi.fn(); | ||
(useWaitForTransactionReceipt as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
data: { status: 'success' }, | ||
}); | ||
(useCallsStatus as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
transactionHash: 'hash', | ||
}); | ||
render( | ||
<TransactionProvider | ||
address="0x123" | ||
contracts={[]} | ||
onSuccess={onSuccessMock} | ||
> | ||
<TestComponent /> | ||
</TransactionProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(onSuccessMock).toHaveBeenCalledWith({ | ||
transactionReceipts: [{ status: 'success' }], | ||
}); | ||
}); | ||
}); | ||
|
||
it('should handle chain switching', async () => { | ||
const switchChainAsyncMock = vi.fn(); | ||
(useSwitchChain as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
|
@@ -382,34 +365,6 @@ describe('TransactionProvider', () => { | |
); | ||
}); | ||
}); | ||
|
||
it('should call onSuccess when receiptArray has receipts', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same for this one. I am rewriting the entire logic in a more simple way so we can actually test this. |
||
const onSuccessMock = vi.fn(); | ||
const mockReceipt = { status: 'success' }; | ||
|
||
(useWaitForTransactionReceipt as ReturnType<typeof vi.fn>).mockReturnValue({ | ||
data: mockReceipt, | ||
}); | ||
|
||
render( | ||
<TransactionProvider | ||
address="0x123" | ||
contracts={[]} | ||
onSuccess={onSuccessMock} | ||
> | ||
<TestComponent /> | ||
</TransactionProvider>, | ||
); | ||
|
||
const button = screen.getByText('Submit'); | ||
fireEvent.click(button); | ||
|
||
await waitFor(() => { | ||
expect(onSuccessMock).toHaveBeenCalledWith({ | ||
transactionReceipts: [mockReceipt], | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('useTransactionContext', () => { | ||
|
This file contains 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
Empty file.
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.
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.
Apperently this test was not testing what was suppose to test 🤦🏻♂️