Skip to content

Commit

Permalink
add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alissacrane-cb committed Aug 9, 2024
1 parent 077df47 commit f64c051
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/transaction/hooks/useGetTransactionStatus.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ describe('useGetTransactionStatus', () => {
expect(result.current.actionElement).not.toBeNull();
});

it('should return correct status and actionElement when transaction id exists', () => {
(useTransactionContext as vi.Mock).mockReturnValue({
transactionId: 'ab123',
});

const { result } = renderHook(() => useGetTransactionStatus());

expect(result.current.label).toBe('Transaction in progress...');
expect(result.current.actionElement).not.toBeNull();
});

it('should return correct status and actionElement when receipt exists', () => {
(useTransactionContext as vi.Mock).mockReturnValue({
receipt: 'receipt',
Expand Down
22 changes: 22 additions & 0 deletions src/transaction/hooks/useGetTransactionToast.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ describe('useGetTransactionToast', () => {
expect(result.current.actionElement).not.toBeNull();
});

it('should return correct status and actionElement when transaction id exists', () => {
(useTransactionContext as vi.Mock).mockReturnValue({
transactionId: 'ab123',
});

const { result } = renderHook(() => useGetTransactionToast());

expect(result.current.label).toBe('Transaction in progress');
expect(result.current.actionElement).not.toBeNull();
});

it('should return correct status and actionElement when transaction hash exists', () => {
(useTransactionContext as vi.Mock).mockReturnValue({
transactionHash: 'ab123',
});

const { result } = renderHook(() => useGetTransactionToast());

expect(result.current.label).toBe('Transaction in progress');
expect(result.current.actionElement).not.toBeNull();
});

it('should return correct toast and actionElement when error occurs', () => {
(useTransactionContext as vi.Mock).mockReturnValue({
errorMessage: 'error',
Expand Down

0 comments on commit f64c051

Please sign in to comment.