2022-06-01 14:21:36 +00:00
|
|
|
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', () => {
|
2022-10-03 18:12:34 +00:00
|
|
|
render(generateJsx({ pubKey: null }));
|
2022-06-01 14:21:36 +00:00
|
|
|
expect(screen.queryByTestId('child')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders children if connected', () => {
|
2022-10-03 18:12:34 +00:00
|
|
|
render(generateJsx({ pubKey: '0x123' }));
|
2022-06-01 14:21:36 +00:00
|
|
|
expect(screen.getByTestId('child')).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
});
|