-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ebe3d4
commit 630fdc8
Showing
7 changed files
with
9,344 additions
and
6,855 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import '@testing-library/jest-dom'; | ||
import matchers from '@testing-library/jest-dom/matchers'; | ||
import { cleanup } from '@testing-library/react'; | ||
|
||
expect.extend(matchers); | ||
|
||
afterEach(() => { | ||
cleanup(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { render } from '@testing-library/react'; | ||
import { MockProviderOptions } from '@wagmi/connectors/mock'; | ||
import { Wallet } from 'ethers'; | ||
import React, { ReactElement } from 'react'; | ||
import { Chain, configureChains, createClient, WagmiConfig } from 'wagmi'; | ||
import { arbitrum, mainnet, optimism, polygon } from 'wagmi/chains'; | ||
import { MockConnector } from 'wagmi/connectors/mock'; | ||
import { publicProvider } from 'wagmi/providers/public'; | ||
import { | ||
RainbowKitProvider, | ||
RainbowKitProviderProps, | ||
} from '../src/components/RainbowKitProvider/RainbowKitProvider'; | ||
|
||
const defaultSigner = new Wallet( | ||
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80' // first anvil pk | ||
); | ||
|
||
const defaultSupportedChains = [mainnet, arbitrum, polygon, optimism]; | ||
|
||
export const renderWithProvider = ( | ||
component: ReactElement, | ||
{ | ||
connectorOptions, | ||
rainbowKit = { chains: defaultSupportedChains }, | ||
supportedChains = defaultSupportedChains, | ||
}: { | ||
supportedChains?: Chain[]; | ||
rainbowKit?: Omit<RainbowKitProviderProps, 'children' | 'chains'> & { | ||
chains?: Chain[]; | ||
}; | ||
connectorOptions?: Partial<MockProviderOptions>; | ||
} = {} as any | ||
) => { | ||
const { chains, provider } = configureChains(supportedChains, [ | ||
publicProvider(), // anvil? | ||
]); | ||
const wagmiClient = createClient({ | ||
autoConnect: true, | ||
connectors: [ | ||
new MockConnector({ | ||
chains, | ||
options: { | ||
chainId: mainnet.id, | ||
flags: { isAuthorized: true }, | ||
signer: defaultSigner, | ||
...connectorOptions, | ||
}, | ||
}), | ||
], | ||
provider, | ||
}); | ||
|
||
const rainbowKitProps = { | ||
...rainbowKit, | ||
chains: rainbowKit.chains || defaultSupportedChains, | ||
}; | ||
|
||
return render(component, { | ||
wrapper: ({ children }) => ( | ||
<WagmiConfig client={wagmiClient}> | ||
<RainbowKitProvider {...rainbowKitProps} children={children} /> | ||
</WagmiConfig> | ||
), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'; | ||
import { defineConfig } from 'vitest/config'; | ||
|
||
export default defineConfig({ | ||
plugins: [vanillaExtractPlugin() as any], // plugin type is broken, not sure, think it's mismatching vite/vitest versions | ||
test: { | ||
environment: 'jsdom', | ||
globals: true, | ||
setupFiles: './test/setup.ts', | ||
watch: false, | ||
}, | ||
}); |
Oops, something went wrong.