add test coverage

This commit is contained in:
Dexter 2021-12-14 13:16:18 +00:00
parent b2ddfec8c6
commit 353e7c8991
2 changed files with 42 additions and 1 deletions

View File

@ -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
}
}
}
}

View File

@ -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(<EtherscanLink chainId={null} address="address" />);
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for tx if chainid is null", () => {
render(<EtherscanLink chainId={null} tx="tx" />);
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for address if chainid is unknown", () => {
// @ts-ignore
render(<EtherscanLink chainId={"foo"} address="address" />);
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});
test("Doesn't render for tx if chainid is unknown", () => {
// @ts-ignore
render(<EtherscanLink chainId={"foo"} tx="tx" />);
expect(screen.queryByTestId("etherscan-link")).not.toBeInTheDocument();
});