37a6217169
* chore: break down components to smaller chunks for better performance * chore: break down components to smaller chunks for better performance * chore: break down components to smaller chunks for better performance - fix failing tests * chore: break down components to smaller chunks for better performance - adjust token app cases * chore: break down components to smaller chunks for better performance - small fixes * chore: break down components to smaller chunks for better performance - small fixes * chore: break down components to smaller chunks for better performance - small fixes * chore: break down components to smaller chunks for better performance - small fixes * chore: break down components to smaller chunks for better performance - add nwe store for pageTitle * chore: break down components to smaller chunks for better performance - sm fix * chore: break down components to smaller chunks for better performance - sm fix * chore: break down components to smaller chunks for better performance - sm imprv * chore: break down components to smaller chunks for better performance - change prop names * chore: break down components to smaller chunks for better performance - fix some test * chore: break down components to smaller chunks for better performance - change cypress url * chore: break down components to smaller chunks for better perf - set back redundant changes * chore: resolve conflicts Co-authored-by: maciek <maciek@vegaprotocol.io>
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { fireEvent, render, screen } from '@testing-library/react';
|
|
import { VegaWalletContext } from '@vegaprotocol/wallet';
|
|
import type { VegaWalletContextShape } from '@vegaprotocol/wallet';
|
|
import { VegaWalletConnectButton } from './vega-wallet-connect-button';
|
|
import { truncateByChars } from '@vegaprotocol/react-helpers';
|
|
|
|
const mockUpdateDialogOpen = jest.fn();
|
|
jest.mock('@vegaprotocol/wallet', () => ({
|
|
...jest.requireActual('@vegaprotocol/wallet'),
|
|
useVegaWalletDialogStore: () => ({
|
|
openVegaWalletDialog: mockUpdateDialogOpen,
|
|
}),
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
const generateJsx = (context: VegaWalletContextShape) => {
|
|
return (
|
|
<VegaWalletContext.Provider value={context}>
|
|
<VegaWalletConnectButton />
|
|
</VegaWalletContext.Provider>
|
|
);
|
|
};
|
|
|
|
it('Not connected', () => {
|
|
render(generateJsx({ pubKey: null } as VegaWalletContextShape));
|
|
|
|
const button = screen.getByRole('button');
|
|
expect(button).toHaveTextContent('Connect Vega wallet');
|
|
fireEvent.click(button);
|
|
expect(mockUpdateDialogOpen).toHaveBeenCalled();
|
|
});
|
|
|
|
it('Connected', () => {
|
|
const pubKey = { publicKey: '123456__123456', name: 'test' };
|
|
render(
|
|
generateJsx({
|
|
pubKey: pubKey.publicKey,
|
|
pubKeys: [pubKey],
|
|
} as VegaWalletContextShape)
|
|
);
|
|
|
|
const button = screen.getByRole('button');
|
|
expect(button).toHaveTextContent(truncateByChars(pubKey.publicKey));
|
|
fireEvent.click(button);
|
|
expect(mockUpdateDialogOpen).not.toHaveBeenCalled();
|
|
});
|