-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d31feb1
commit 3afe980
Showing
13 changed files
with
128 additions
and
8 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe, test, expect } from 'vitest' | ||
import { render, screen } from '@testing-library/react' | ||
import { Preview } from './Preview' | ||
|
||
describe('Preview component', () => { | ||
test('renders without crashing', () => { | ||
render(<Preview />) | ||
expect(screen.getByText('You are')).toBeInTheDocument() | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe, test, expect } from 'vitest' | ||
import { render, screen } from '@testing-library/react' | ||
import { Success } from './Success' | ||
|
||
describe('Success component', () => { | ||
test('renders without crashing', () => { | ||
render(<Success />) | ||
expect(screen.getByText(`You're amazing, thanks!`)).toBeInTheDocument() | ||
}) | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { test, expect, vi } from 'vitest' | ||
import { prepare } from './prepare' | ||
import * as wagmiActionsMock from '../../../../../test/__mocks__/wagmi/actions' | ||
|
||
test('prepare with undefined params', async () => { | ||
try { | ||
await prepare(undefined, undefined, undefined, undefined) | ||
expect(true).toBe(false) | ||
} catch (e) { | ||
expect(true).toBe(true) | ||
} | ||
}) | ||
|
||
test('prepare with isNative true uses correct method', async () => { | ||
const selectedToken = { | ||
address: '0x0', | ||
decimals: 18 | ||
// Add other required properties here | ||
} | ||
|
||
const amount = '1' | ||
const to = '0xabcdef1234567890' | ||
const chainId = 1 | ||
|
||
const spy = vi.spyOn(wagmiActionsMock, 'prepareSendTransaction') | ||
await prepare(selectedToken as any, amount, to, chainId) | ||
expect(spy).toHaveBeenCalledOnce() | ||
}) | ||
|
||
test('prepare with isNative false uses correct method', async () => { | ||
const selectedToken = { | ||
address: '0xabcdef1234567890', | ||
decimals: 18 | ||
} | ||
|
||
const amount = '1' | ||
const to = '0xabcdef1234567890' | ||
const chainId = 1 | ||
|
||
const spy = vi.spyOn(wagmiActionsMock, 'prepareWriteContract') | ||
await prepare(selectedToken as any, amount, to, chainId) | ||
expect(spy).toHaveBeenCalledOnce() | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { test, expect, vi } from 'vitest' | ||
import { send } from './send' | ||
import * as wagmiActionsMock from '../../../../../test/__mocks__/wagmi/actions' | ||
|
||
test('with undefined params', async () => { | ||
const result = await send(undefined, undefined) | ||
expect(result).toBeUndefined() | ||
}) | ||
|
||
test('with isNative true uses correct method', async () => { | ||
const selectedToken = { | ||
address: '0x0', | ||
decimals: 18 | ||
} | ||
|
||
const spy = vi.spyOn(wagmiActionsMock, 'sendTransaction') | ||
await send(selectedToken as any, {} as any) | ||
expect(spy).toHaveBeenCalledOnce() | ||
}) | ||
|
||
test('with isNative false uses correct method', async () => { | ||
const selectedToken = { | ||
address: '0xabcdef1234567890', | ||
decimals: 18 | ||
} | ||
|
||
const spy = vi.spyOn(wagmiActionsMock, 'writeContract') | ||
await send(selectedToken as any, {} as any) | ||
expect(spy).toHaveBeenCalledOnce() | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './truncateAddress' |
11 changes: 11 additions & 0 deletions
11
src/features/Web3/lib/truncateAddress/truncateAddress.test.ts
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test, expect } from 'vitest' | ||
import { truncateAddress } from './truncateAddress' | ||
|
||
test('truncateAddress', () => { | ||
const address = '0x1234567890abcdef' | ||
const truncated = truncateAddress(address) | ||
|
||
expect(truncated.startsWith('0x1234')).toBe(true) | ||
expect(truncated.endsWith('cdef')).toBe(true) | ||
expect(truncated).toBe('0x1234...cdef') | ||
}) |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const prepareSendTransaction = async () => { | ||
return {} | ||
} | ||
|
||
export const prepareWriteContract = async () => { | ||
return {} | ||
} | ||
|
||
export const sendTransaction = async () => { | ||
return {} | ||
} | ||
|
||
export const writeContract = async () => { | ||
return {} | ||
} |
File renamed without changes.
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