Skip to content

Commit

Permalink
chore: added LoginButton and SignupButton test (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: Alissa Crane <[email protected]>
  • Loading branch information
cpcramer and alissacrane-cb authored Aug 8, 2024
1 parent fd8a462 commit efa36d0
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/components/LoginButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { http, WagmiProvider, createConfig } from 'wagmi';
import { base } from 'wagmi/chains';
import { mock } from 'wagmi/connectors';
import LoginButton from './LoginButton';

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(
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
{component}
</QueryClientProvider>
</WagmiProvider>,
);
};

describe('LoginButton', () => {
it('should render', () => {
renderWithProviders(<LoginButton />);
const walletWrapper = screen.getByTestId('ockConnectWallet_Container');
expect(walletWrapper).toBeInTheDocument();
});
});
43 changes: 43 additions & 0 deletions src/components/SignupButton.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { http, WagmiProvider, createConfig } from 'wagmi';
import { base } from 'wagmi/chains';
import { mock } from 'wagmi/connectors';
import SignupButton from './SignupButton';

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(
<WagmiProvider config={config}>
<QueryClientProvider client={queryClient}>
{component}
</QueryClientProvider>
</WagmiProvider>,
);
};

describe('SignupButton', () => {
it('should render', () => {
renderWithProviders(<SignupButton />);
const wallet = screen.getByTestId('ockConnectWallet_Container');
expect(wallet).toBeInTheDocument();
});
});

0 comments on commit efa36d0

Please sign in to comment.