import { render, screen } from "@testing-library/react";
import * as React from "react";
import { EtherscanLink } from ".";
import { EthereumChainIds } from "../../utils/web3";
test("It renders a link with the text", () => {
render(
);
expect(screen.getByText("foo")).toBeInTheDocument();
});
test("It renders a link with the tx hash if no text is provided", () => {
render();
expect(screen.getByText("tx")).toBeInTheDocument();
});
test("It renders a link with the address if no text is provided", () => {
render(
);
expect(screen.getByText("address")).toBeInTheDocument();
});
test("It links to etherscan if network is mainnet", () => {
render(
);
expect(screen.getByTestId("etherscan-link")).toHaveAttribute(
"href",
"https://etherscan.io/address/address"
);
});
test("It links to ropsten etherscan if network is ropsten", () => {
render(
);
expect(screen.getByTestId("etherscan-link")).toHaveAttribute(
"href",
"https://ropsten.etherscan.io/address/address"
);
});
test("Doesn't render for address if chainid is null", () => {
render();
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for tx if chainid is null", () => {
render();
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for address if chainid is unknown", () => {
// @ts-ignore
render();
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for tx if chainid is unknown", () => {
// @ts-ignore
render();
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});