diff --git a/package.json b/package.json
index d34022f30..a4906649e 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"build": "rollup -c && yarn build:types",
"build:types": "tsc",
"test": "react-scripts test",
+ "test:coverage": "yarn test --coverage --watchAll=false ",
"eject": "react-scripts eject",
"storybook": "start-storybook -p 6006 -s public",
"build-storybook": "build-storybook -s public"
@@ -99,5 +100,23 @@
"homepage": "https://github.com/vegaprotocol/ui-toolkit",
"keywords": [
"vega"
- ]
+ ],
+ "jest": {
+ "collectCoverageFrom": [
+ "**/**/*.{ts,tsx}",
+ "!**/**/*.stories.tsx"
+ ],
+ "coverageReporters": [
+ "html",
+ "json"
+ ],
+ "coverageThreshold": {
+ "global": {
+ "branches": 100,
+ "functions": 100,
+ "lines": 100,
+ "statements": 100
+ }
+ }
+ }
}
diff --git a/src/components/etherscan-link/etherscan-link.test.tsx b/src/components/etherscan-link/etherscan-link.test.tsx
index 7ff6b6723..8e7d9a146 100644
--- a/src/components/etherscan-link/etherscan-link.test.tsx
+++ b/src/components/etherscan-link/etherscan-link.test.tsx
@@ -41,3 +41,25 @@ test("It links to ropsten etherscan if network is ropsten", () => {
"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();
+});