Skip to content

Commit

Permalink
test: context
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed May 22, 2024
1 parent d561579 commit a9ddfe0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/react/src/context.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { render, screen } from '@testing-library/react'
import { config } from '@wagmi/test'
import React from 'react'
import { expect, test } from 'vitest'

import { WagmiProvider } from './context.js'
import { useAccount } from './hooks/useAccount.js'
import { useConnectorClient } from './hooks/useConnectorClient.js'

test('default', () => {
function Component() {
const { address } = useAccount()
const { data } = useConnectorClient()
return (
<div>
<h1>wevm</h1>
<div>useAccount: {address}</div>
<div>useConnectorClient: {data?.account?.address}</div>
</div>
)
}

const queryClient = new QueryClient()
render(
<WagmiProvider config={config} reconnectOnMount>
<QueryClientProvider client={queryClient}>
<Component />
</QueryClientProvider>
</WagmiProvider>,
)
expect(screen.getByRole('heading').innerText).toMatchInlineSnapshot(`"wevm"`)
})

0 comments on commit a9ddfe0

Please sign in to comment.