Skip to content

Commit 1a86f58

Browse files
test: use top-level import in SignButton tests
Replace per-test dynamic imports with a standard static import, matching the pattern used in TransactionButton and SwitchNetwork tests. Closes #455
1 parent b2d4034 commit 1a86f58

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

src/components/sharedComponents/SignButton.test.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, screen } from '@testing-library/react'
33
import type { ReactNode } from 'react'
44
import { createElement } from 'react'
55
import { beforeEach, describe, expect, it, vi } from 'vitest'
6+
import SignButton from './SignButton'
67

78
const mockSwitchChain = vi.fn()
89
const mockSignMessageAsync = vi.fn()
@@ -54,7 +55,7 @@ describe('SignButton', () => {
5455
vi.clearAllMocks()
5556
})
5657

57-
it('renders connect button when wallet needs connect', async () => {
58+
it('renders connect button when wallet needs connect', () => {
5859
mockedUseWalletStatus.mockReturnValue({
5960
isReady: false,
6061
needsConnect: true,
@@ -64,15 +65,13 @@ describe('SignButton', () => {
6465
switchChain: mockSwitchChain,
6566
})
6667

67-
const { default: SignButton } = await import('./SignButton')
68-
6968
renderWithChakra(<SignButton message="Hello" />)
7069

7170
expect(screen.getByTestId('connect-wallet-button')).toBeInTheDocument()
7271
expect(screen.queryByText('Sign Message')).toBeNull()
7372
})
7473

75-
it('renders custom fallback when provided and wallet needs connect', async () => {
74+
it('renders custom fallback when provided and wallet needs connect', () => {
7675
mockedUseWalletStatus.mockReturnValue({
7776
isReady: false,
7877
needsConnect: true,
@@ -82,8 +81,6 @@ describe('SignButton', () => {
8281
switchChain: mockSwitchChain,
8382
})
8483

85-
const { default: SignButton } = await import('./SignButton')
86-
8784
renderWithChakra(
8885
<SignButton
8986
message="Hello"
@@ -95,7 +92,7 @@ describe('SignButton', () => {
9592
expect(screen.queryByText('Sign Message')).toBeNull()
9693
})
9794

98-
it('renders switch chain button when wallet needs chain switch', async () => {
95+
it('renders switch chain button when wallet needs chain switch', () => {
9996
mockedUseWalletStatus.mockReturnValue({
10097
isReady: false,
10198
needsConnect: false,
@@ -107,16 +104,14 @@ describe('SignButton', () => {
107104
switchChain: mockSwitchChain,
108105
})
109106

110-
const { default: SignButton } = await import('./SignButton')
111-
112107
renderWithChakra(<SignButton message="Hello" />)
113108

114109
expect(screen.getByText(/Switch to/)).toBeInTheDocument()
115110
expect(screen.getByText(/OP Mainnet/)).toBeInTheDocument()
116111
expect(screen.queryByText('Sign Message')).toBeNull()
117112
})
118113

119-
it('renders sign button when wallet is ready', async () => {
114+
it('renders sign button when wallet is ready', () => {
120115
mockedUseWalletStatus.mockReturnValue({
121116
isReady: true,
122117
needsConnect: false,
@@ -126,8 +121,6 @@ describe('SignButton', () => {
126121
switchChain: mockSwitchChain,
127122
})
128123

129-
const { default: SignButton } = await import('./SignButton')
130-
131124
renderWithChakra(<SignButton message="Hello" />)
132125

133126
expect(screen.getByText('Sign Message')).toBeInTheDocument()

0 commit comments

Comments
 (0)