From c918e11746e8878d856207fe45693b70c6c46b5b Mon Sep 17 00:00:00 2001 From: Paul Cramer Date: Thu, 8 Aug 2024 13:23:22 -0700 Subject: [PATCH] Add test for LoginButton and SignupButton --- src/components/LoginButton.test.tsx | 43 ++++++++++++++++++++++++++++ src/components/SignupButton.test.tsx | 43 ++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 src/components/LoginButton.test.tsx create mode 100644 src/components/SignupButton.test.tsx diff --git a/src/components/LoginButton.test.tsx b/src/components/LoginButton.test.tsx new file mode 100644 index 0000000..9d4c772 --- /dev/null +++ b/src/components/LoginButton.test.tsx @@ -0,0 +1,43 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import LoginButton from './LoginButton'; +import { http, WagmiProvider, createConfig } from 'wagmi'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { base } from 'wagmi/chains'; +import { mock } from 'wagmi/connectors'; + +const config = createConfig({ + chains: [base], + connectors: [ + mock({ + accounts: [ + '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', + '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', + '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', + ], + }), + ], + transports: { + [base.id]: http(), + }, +}); + +const queryClient = new QueryClient(); + +const renderWithProviders = (component: JSX.Element) => { + return render( + + + {component} + + , + ); +}; + +describe('LoginButton', () => { + it('should render', () => { + renderWithProviders(); + const walletWrapper = screen.getByTestId('ockConnectWallet_Container'); + expect(walletWrapper).toBeInTheDocument(); + }); + }); diff --git a/src/components/SignupButton.test.tsx b/src/components/SignupButton.test.tsx new file mode 100644 index 0000000..b2d95ae --- /dev/null +++ b/src/components/SignupButton.test.tsx @@ -0,0 +1,43 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it } from 'vitest'; +import SignupButton from './SignupButton'; +import { http, WagmiProvider, createConfig } from 'wagmi'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { base } from 'wagmi/chains'; +import { mock } from 'wagmi/connectors'; + +const config = createConfig({ + chains: [base], + connectors: [ + mock({ + accounts: [ + '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', + '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', + '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC', + ], + }), + ], + transports: { + [base.id]: http(), + }, +}); + +const queryClient = new QueryClient(); + +const renderWithProviders = (component: JSX.Element) => { + return render( + + + {component} + + , + ); +}; + +describe('SignupButton', () => { + it('should render', () => { + renderWithProviders(); + const wallet = screen.getByTestId('ockConnectWallet_Container'); + expect(wallet).toBeInTheDocument(); + }); +});