From f3664f8fc0ef0cf4d429d19c60906ac4fd860c18 Mon Sep 17 00:00:00 2001 From: Sergei Novikov Date: Wed, 29 Nov 2023 11:04:15 +0300 Subject: [PATCH] solution: fix tests --- packages/react-app/jest.setup.ts | 8 +++++--- packages/react-app/tsconfig.json | 13 ++----------- packages/store/src/txstash/handler/handler.ts | 9 +++++++-- packages/ui/jest.setup.ts | 2 +- packages/ui/tsconfig.json | 17 +++-------------- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/packages/react-app/jest.setup.ts b/packages/react-app/jest.setup.ts index 9a9c1ce92..618eb2365 100644 --- a/packages/react-app/jest.setup.ts +++ b/packages/react-app/jest.setup.ts @@ -1,9 +1,11 @@ import { TextDecoder, TextEncoder } from 'util'; import * as Enzyme from 'enzyme'; -import * as Adapter from 'enzyme-adapter-react-16'; +import Adapter from 'enzyme-adapter-react-16'; import 'jest-canvas-mock'; -global.TextEncoder = TextEncoder; -global.TextDecoder = TextDecoder; +Object.defineProperties(globalThis, { + TextDecoder: { value: TextDecoder }, + TextEncoder: { value: TextEncoder }, +}); Enzyme.configure({ adapter: new Adapter() }); diff --git a/packages/react-app/tsconfig.json b/packages/react-app/tsconfig.json index 3e57ab95b..9ab787b85 100644 --- a/packages/react-app/tsconfig.json +++ b/packages/react-app/tsconfig.json @@ -2,22 +2,13 @@ "extends": "../../tsconfig.json", "compilerOptions": { "allowSyntheticDefaultImports": true, - "esModuleInterop": false, "jsx": "react", "outDir": "lib/", "resolveJsonModule": true, "rootDir": "src/" }, - "exclude": [ - "node_modules", - "**/*.spec.ts", - "**/*.spec.tsx" - ], - "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/i18n/locales/**/*.json" - ], + "exclude": ["node_modules", "**/*.spec.ts", "**/*.spec.tsx"], + "include": ["src/**/*.ts", "src/**/*.tsx", "src/i18n/locales/**/*.json"], "references": [ { "path": "../core" diff --git a/packages/store/src/txstash/handler/handler.ts b/packages/store/src/txstash/handler/handler.ts index 830015b04..67251a953 100644 --- a/packages/store/src/txstash/handler/handler.ts +++ b/packages/store/src/txstash/handler/handler.ts @@ -1,7 +1,12 @@ import { WalletEntry, isBitcoinEntry } from '@emeraldpay/emerald-vault-core'; import { EthereumRawTransaction, decodeData, isEthereumRawTransaction, workflow } from '@emeraldwallet/core'; import { TxAction } from '../types'; -import { prepareEthereumTransaction, restoreBitcoinTransaction, restoreEthereumTransaction } from './blockchain'; +import { + prepareBitcoinTransaction, + prepareEthereumTransaction, + restoreBitcoinTransaction, + restoreEthereumTransaction, +} from './blockchain'; import { Data, Handler, StoreProvider } from './types'; function ethereumTxTypeSelector(rawTx: EthereumRawTransaction, whenEther: T, whenContract: T): T { @@ -36,7 +41,7 @@ export function getHandler(data: Data, storeProvider: StoreProvider storeProvider, ); case TxAction.TRANSFER: - return restoreBitcoinTransaction( + return prepareBitcoinTransaction( { ...data, entry }, { getTxMetaType() { diff --git a/packages/ui/jest.setup.ts b/packages/ui/jest.setup.ts index a979ce409..18975afc2 100644 --- a/packages/ui/jest.setup.ts +++ b/packages/ui/jest.setup.ts @@ -1,5 +1,5 @@ import * as Enzyme from 'enzyme'; -import * as Adapter from 'enzyme-adapter-react-16'; +import Adapter from 'enzyme-adapter-react-16'; import 'jest-canvas-mock'; Enzyme.configure({ adapter: new Adapter() }); diff --git a/packages/ui/tsconfig.json b/packages/ui/tsconfig.json index 2b415deed..2edc4a359 100644 --- a/packages/ui/tsconfig.json +++ b/packages/ui/tsconfig.json @@ -2,25 +2,14 @@ "extends": "../../tsconfig.json", "compilerOptions": { "allowSyntheticDefaultImports": true, - "esModuleInterop": false, "jsx": "react", "outDir": "lib/", "rootDir": "src/", "strict": false, - "typeRoots": [ - "../../node_modules/@types", - "node_modules/@types" - ] + "typeRoots": ["../../node_modules/@types", "node_modules/@types"] }, - "exclude": [ - "node_modules", - "**/*.spec.ts", - "**/*.spec.tsx" - ], - "include": [ - "src/**/*.ts", - "src/**/*.tsx" - ], + "exclude": ["node_modules", "**/*.spec.ts", "**/*.spec.tsx"], + "include": ["src/**/*.ts", "src/**/*.tsx"], "references": [ { "path": "../core"