Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Nov 21, 2024
1 parent 22f8808 commit a5441d0
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 79 deletions.
64 changes: 37 additions & 27 deletions src/OnchainKitProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useConfig } from 'wagmi';
import { mock } from 'wagmi/connectors';
import { setOnchainKitConfig } from './OnchainKitConfig';
import { OnchainKitProvider } from './OnchainKitProvider';
import { COINBASE_VERIFIED_ACCOUNT_SCHEMA_ID } from './identity/constants';
import type { EASSchemaUid } from './identity/types';
import { useOnchainKit } from './useOnchainKit';
import { useProviderDependencies } from './useProviderDependencies';
Expand Down Expand Up @@ -184,6 +183,11 @@ describe('OnchainKitProvider', () => {
theme: 'default',
},
paymaster: paymasterUrl,
wallet: {
display: 'classic',
termsUrl: undefined,
privacyUrl: undefined,
},
},
chain: base,
rpcUrl: null,
Expand Down Expand Up @@ -214,22 +218,32 @@ describe('OnchainKitProvider', () => {
theme: 'default',
},
paymaster: null,
wallet: {
display: 'classic',
termsUrl: undefined,
privacyUrl: undefined,
},
},
}),
);
});
});

it('should use default values for appearance when config is provided', async () => {
it('should use custom values when override in config is provided', async () => {
const customConfig = {
appearance: {},
appearance: {
name: 'custom name',
logo: 'https://example.com/logo.png',
},
paymaster: 'https://example.com',
};

render(
<WagmiProvider config={mockConfig}>
<QueryClientProvider client={queryClient}>
<OnchainKitProvider
chain={base}
schemaId={schemaId}
apiKey={apiKey}
config={customConfig}
>
Expand All @@ -247,28 +261,33 @@ describe('OnchainKitProvider', () => {
chain: base,
config: {
appearance: {
logo: appLogo,
name: appName,
name: 'custom name',
logo: 'https://example.com/logo.png',
mode: 'auto',
theme: 'default',
},
paymaster: paymasterUrl,
paymaster: 'https://example.com',
wallet: {
display: 'classic',
termsUrl: undefined,
privacyUrl: undefined,
},
},
projectId: null,
rpcUrl: null,
schemaId: COINBASE_VERIFIED_ACCOUNT_SCHEMA_ID,
schemaId: schemaId,
}),
);
});
});

it('should use custom values when override in config is provided', async () => {
it('should use custom wallet config when provided', async () => {
const customConfig = {
appearance: {
name: 'custom name',
logo: 'https://example.com/logo.png',
wallet: {
display: 'modal',
termsUrl: 'https://example.com/terms',
privacyUrl: 'https://example.com/privacy',
},
paymaster: 'https://example.com',
};

render(
Expand All @@ -277,7 +296,6 @@ describe('OnchainKitProvider', () => {
<OnchainKitProvider
chain={base}
schemaId={schemaId}
apiKey={apiKey}
config={customConfig}
>
<TestComponent />
Expand All @@ -289,21 +307,13 @@ describe('OnchainKitProvider', () => {
await waitFor(() => {
expect(setOnchainKitConfig).toHaveBeenCalledWith(
expect.objectContaining({
address: null,
apiKey: apiKey,
chain: base,
config: {
appearance: {
name: 'custom name',
logo: 'https://example.com/logo.png',
mode: 'auto',
theme: 'default',
config: expect.objectContaining({
wallet: {
display: 'modal',
termsUrl: 'https://example.com/terms',
privacyUrl: 'https://example.com/privacy',
},
paymaster: 'https://example.com',
},
projectId: null,
rpcUrl: null,
schemaId: schemaId,
}),
}),
);
});
Expand Down
Loading

0 comments on commit a5441d0

Please sign in to comment.