vega-frontend-monorepo/apps/trading/components/footer/footer.spec.tsx
Matthew Russell 9b360af2c1
feat(#862): show current node and button to open node switcher (#1894)
* feat: add node url to footer, add link to change node

* feat: add test for trading footer

* chore: add comment about url manipulation

* fix: #862 fix cypress tests

* fix: #862 remove constant link

Co-authored-by: Madalina Raicu <madalina@raygroup.uk>
2022-11-07 16:53:43 -08:00

27 lines
830 B
TypeScript

import { fireEvent, render, screen } from '@testing-library/react';
import { Footer } from './footer';
import { useEnvironment } from '@vegaprotocol/environment';
jest.mock('@vegaprotocol/environment');
describe('Footer', () => {
it('renders a button to open node switcher', () => {
const mockOpenNodeSwitcher = jest.fn();
const node = 'n99.somenetwork.vega.xyz';
const nodeUrl = `https://${node}`;
// @ts-ignore mock env hook
useEnvironment.mockImplementation(() => ({
VEGA_URL: `https://api.${node}/graphql`,
setNodeSwitcherOpen: mockOpenNodeSwitcher,
}));
render(<Footer />);
fireEvent.click(screen.getByRole('button'));
expect(mockOpenNodeSwitcher).toHaveBeenCalled();
const link = screen.getByText(node);
expect(link).toHaveAttribute('href', nodeUrl);
});
});