diff --git a/package.json b/package.json index d47e36162..e60745919 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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$": "/node_modules/react-scripts/node_modules/babel-jest" + }, + "transformIgnorePatterns": [ + "/node_modules/(?!@project-serum/sol-wallet-adapter)" + ] } } diff --git a/src/App.test.tsx b/src/App.test.tsx index 352d7b8ff..78f1bfb9a 100644 --- a/src/App.test.tsx +++ b/src/App.test.tsx @@ -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(); - const linkElement = getByText(/learn react/i); + const linkElement = getByText(/Your balances/i); expect(linkElement).toBeInTheDocument(); }); diff --git a/src/setupTests.ts b/src/setupTests.ts index 5fdf00169..46e158eb6 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -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: () => {} + }; + } +}) diff --git a/src/types/sol-wallet-adapter.d.ts b/src/types/sol-wallet-adapter.d.ts deleted file mode 100644 index 6464233b3..000000000 --- a/src/types/sol-wallet-adapter.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module "@project-serum/sol-wallet-adapter" { - const adapter: any; - export = adapter; -} diff --git a/tsconfig.json b/tsconfig.json index c30c01798..fd01e0a7e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "downlevelIteration": true, "resolveJsonModule": true, "noEmit": true, - "typeRoots": ["./types"], + "typeRoots": ["./types", "./node_modules/@types"], "jsx": "react", "isolatedModules": true }, diff --git a/yarn.lock b/yarn.lock index 052bf74c2..cc4b8fe0f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"