Skip to content

Commit

Permalink
Merge pull request #24 from ebramanti/fix-jest-tests
Browse files Browse the repository at this point in the history
Fix Jest test runner
  • Loading branch information
bartosz-lipinski authored Jul 26, 2021
2 parents 3fc3f4d + 105a608 commit 569a74d
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 12 deletions.
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@craco/craco": "^5.7.0",
"@ledgerhq/hw-transport-webusb": "^5.41.0",
"@project-serum/serum": "^0.13.34",
"@project-serum/sol-wallet-adapter": "^0.2.0",
"@project-serum/sol-wallet-adapter": "^0.2.4",
"@solana/spl-token": "^0.1.6",
"@solana/spl-token-registry": "^0.2.203",
"@solana/spl-token-swap": "^0.1.0",
Expand Down Expand Up @@ -74,5 +74,13 @@
"arweave-deploy": "^1.9.1",
"gh-pages": "^3.1.0",
"prettier": "^2.1.2"
},
"jest": {
"transform": {
"(@project-serum/sol-wallet-adapter).+\\.js$": "<rootDir>/node_modules/react-scripts/node_modules/babel-jest"
},
"transformIgnorePatterns": [
"/node_modules/(?!@project-serum/sol-wallet-adapter)"
]
}
}
11 changes: 9 additions & 2 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ import React from "react";
import { render } from "@testing-library/react";
import App from "./App";

test("renders learn react link", () => {
jest.mock("./components/Identicon", () => {
return {
__esModule: true,
Identicon: () => null,
};
});

test("renders balances text", () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
const linkElement = getByText(/Your balances/i);
expect(linkElement).toBeInTheDocument();
});
10 changes: 10 additions & 0 deletions src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom/extend-expect";

Object.defineProperty(window, 'matchMedia', {
value: () => {
return {
matches: false,
addListener: () => {},
removeListener: () => {}
};
}
})
4 changes: 0 additions & 4 deletions src/types/sol-wallet-adapter.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"downlevelIteration": true,
"resolveJsonModule": true,
"noEmit": true,
"typeRoots": ["./types"],
"typeRoots": ["./types", "./node_modules/@types"],
"jsx": "react",
"isolatedModules": true
},
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1518,10 +1518,10 @@
bn.js "^5.1.2"
buffer-layout "^1.2.0"

"@project-serum/sol-wallet-adapter@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@project-serum/sol-wallet-adapter/-/sol-wallet-adapter-0.2.0.tgz#e1fa5508bf13110429bf26e10b818182015f2161"
integrity sha512-ed7wZwlDqjF88VCq7eHVO8njHqdUkBxBL8WEVOnB47ooLO4btOJt6GBdkKpKqKX86c86LiEROJclcdW8e7kIjg==
"@project-serum/sol-wallet-adapter@^0.2.4":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@project-serum/sol-wallet-adapter/-/sol-wallet-adapter-0.2.4.tgz#205adc303aea38d6c2043cb644fd70ba2fa758e0"
integrity sha512-NlFD5FumLddrHsRB1Dco7adiproUvXFC8kRxNg8ptEMD7k9p5gr8iKf6t06eARZAWQ7r90Bq1gEJc9GHlZ0c4Q==
dependencies:
bs58 "^4.0.1"
eventemitter3 "^4.0.4"
Expand Down

0 comments on commit 569a74d

Please sign in to comment.