Skip to content

Commit

Permalink
chore: solana adapter ssr crash test (#3358)
Browse files Browse the repository at this point in the history
Co-authored-by: tomiir <rocchitomas@gmail.com>
  • Loading branch information
magiziz and tomiir authored Dec 20, 2024
1 parent f4e1a80 commit dd1ee9a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
32 changes: 32 additions & 0 deletions packages/adapters/solana/src/tests/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { SolanaAdapter } from '../client'
import { SolStoreUtil } from '../utils/SolanaStoreUtil'
import type { WalletStandardProvider } from '../providers/WalletStandardProvider'
import { watchStandard } from '../utils/watchStandard'
import mockAppKit from './mocks/AppKit'
import { mockCoinbaseWallet } from './mocks/CoinbaseWallet'

// Mock external dependencies
vi.mock('@solana/web3.js', () => ({
Expand Down Expand Up @@ -88,6 +90,36 @@ describe('SolanaAdapter', () => {
})
})

describe('SolanaAdapter - syncConnectors', () => {
it('should not add coinbase connector if window.coinbaseSolana does not exist', async () => {
const addConnectorSpy = vi.spyOn(adapter, 'addConnector' as any)
adapter.syncConnectors(
{ networks: [solana], projectId: '123', features: { email: false } },
mockAppKit
)
expect(addConnectorSpy).not.toHaveBeenCalled()
})

it('should add coinbase connector if window.coinbaseSolana exist', async () => {
;(window as any).coinbaseSolana = mockCoinbaseWallet()
const addConnectorSpy = vi.spyOn(adapter, 'addConnector' as any)
adapter.syncConnectors(
{ networks: [solana], projectId: '123', features: { email: false } },
mockAppKit
)
expect(addConnectorSpy).toHaveBeenCalledOnce()
expect(addConnectorSpy).toHaveBeenCalledWith(
expect.objectContaining({
id: 'coinbaseWallet',
type: 'EXTERNAL',
name: 'Coinbase Wallet',
chain: 'solana',
chains: []
})
)
})
})

describe('SolanaAdapter - constructor', () => {
it('should initialize with correct parameters', () => {
expect(adapter.adapterType).toBe('solana')
Expand Down
10 changes: 8 additions & 2 deletions packages/adapters/solana/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { defineProject } from 'vitest/config'
// vitest.config.ts
import { defineConfig } from 'vitest/config'

export default defineProject({})
export default defineConfig({
test: {
// Match test files and set environment
environmentMatchGlobs: [['src/tests/client.test.ts', 'jsdom']]
}
})
2 changes: 1 addition & 1 deletion packages/appkit/exports/constants.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const PACKAGE_VERSION = '1.6.1'
export const PACKAGE_VERSION = '1.6.2'

0 comments on commit dd1ee9a

Please sign in to comment.