chore: remove unused component
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export * from './vega-wallet-container';
|
||||
@@ -1,27 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { VegaWalletContainer } from './vega-wallet-container';
|
||||
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
||||
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
||||
import type { PartialDeep } from 'type-fest';
|
||||
|
||||
const generateJsx = (context: PartialDeep<VegaWalletContextShape>) => {
|
||||
return (
|
||||
<VegaWalletContext.Provider value={context as VegaWalletContextShape}>
|
||||
<VegaWalletContainer>
|
||||
<div data-testid="child" />
|
||||
</VegaWalletContainer>
|
||||
</VegaWalletContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
describe('VegaWalletContainer', () => {
|
||||
it('doesnt render children if not connected', () => {
|
||||
render(generateJsx({ pubKey: null }));
|
||||
expect(screen.queryByTestId('child')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders children if connected', () => {
|
||||
render(generateJsx({ pubKey: '0x123' }));
|
||||
expect(screen.getByTestId('child')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -1,35 +0,0 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { t } from '@vegaprotocol/i18n';
|
||||
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
|
||||
import { useVegaWallet, useVegaWalletDialogStore } from '@vegaprotocol/wallet';
|
||||
|
||||
interface VegaWalletContainerProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => {
|
||||
const { openVegaWalletDialog } = useVegaWalletDialogStore((store) => ({
|
||||
openVegaWalletDialog: store.openVegaWalletDialog,
|
||||
}));
|
||||
const { pubKey } = useVegaWallet();
|
||||
|
||||
if (!pubKey) {
|
||||
return (
|
||||
<Splash>
|
||||
<div className="text-center">
|
||||
<p className="mb-4" data-testid="connect-vega-wallet-text">
|
||||
{t('Connect your Vega wallet')}
|
||||
</p>
|
||||
<Button
|
||||
onClick={openVegaWalletDialog}
|
||||
data-testid="vega-wallet-connect"
|
||||
>
|
||||
{t('Connect')}
|
||||
</Button>
|
||||
</div>
|
||||
</Splash>
|
||||
);
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
Reference in New Issue
Block a user