From eb572ae2b1ff476fb886fb12214fdf9df18759c5 Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Mon, 24 Feb 2025 14:51:22 +0100 Subject: [PATCH] test: prevent jest from picking up helpers --- __tests__/{fiat.ts => fiat.test.ts} | 0 __tests__/{helpers.ts => helpers.test.ts} | 0 __tests__/{i18n.ts => i18n.test.ts} | 0 __tests__/{lightning.ts => lightning.test.ts} | 0 __tests__/{lnurl.ts => lnurl.test.ts} | 0 __tests__/{numberpad.ts => numberpad.test.ts} | 0 __tests__/{reselect.ts => reselect.test.ts} | 0 __tests__/{scanner.ts => scanner.test.ts} | 0 __tests__/{slashtags.ts => slashtags.test.ts} | 0 __tests__/{todos.ts => todos.test.ts} | 0 __tests__/utils/dummy-wallet.ts | 4 ---- __tests__/{wallet.ts => wallet.test.ts} | 7 +++---- jest.config.js | 1 + src/utils/i18n/index.ts | 6 +++++- 14 files changed, 9 insertions(+), 9 deletions(-) rename __tests__/{fiat.ts => fiat.test.ts} (100%) rename __tests__/{helpers.ts => helpers.test.ts} (100%) rename __tests__/{i18n.ts => i18n.test.ts} (100%) rename __tests__/{lightning.ts => lightning.test.ts} (100%) rename __tests__/{lnurl.ts => lnurl.test.ts} (100%) rename __tests__/{numberpad.ts => numberpad.test.ts} (100%) rename __tests__/{reselect.ts => reselect.test.ts} (100%) rename __tests__/{scanner.ts => scanner.test.ts} (100%) rename __tests__/{slashtags.ts => slashtags.test.ts} (100%) rename __tests__/{todos.ts => todos.test.ts} (100%) delete mode 100644 __tests__/utils/dummy-wallet.ts rename __tests__/{wallet.ts => wallet.test.ts} (70%) diff --git a/__tests__/fiat.ts b/__tests__/fiat.test.ts similarity index 100% rename from __tests__/fiat.ts rename to __tests__/fiat.test.ts diff --git a/__tests__/helpers.ts b/__tests__/helpers.test.ts similarity index 100% rename from __tests__/helpers.ts rename to __tests__/helpers.test.ts diff --git a/__tests__/i18n.ts b/__tests__/i18n.test.ts similarity index 100% rename from __tests__/i18n.ts rename to __tests__/i18n.test.ts diff --git a/__tests__/lightning.ts b/__tests__/lightning.test.ts similarity index 100% rename from __tests__/lightning.ts rename to __tests__/lightning.test.ts diff --git a/__tests__/lnurl.ts b/__tests__/lnurl.test.ts similarity index 100% rename from __tests__/lnurl.ts rename to __tests__/lnurl.test.ts diff --git a/__tests__/numberpad.ts b/__tests__/numberpad.test.ts similarity index 100% rename from __tests__/numberpad.ts rename to __tests__/numberpad.test.ts diff --git a/__tests__/reselect.ts b/__tests__/reselect.test.ts similarity index 100% rename from __tests__/reselect.ts rename to __tests__/reselect.test.ts diff --git a/__tests__/scanner.ts b/__tests__/scanner.test.ts similarity index 100% rename from __tests__/scanner.ts rename to __tests__/scanner.test.ts diff --git a/__tests__/slashtags.ts b/__tests__/slashtags.test.ts similarity index 100% rename from __tests__/slashtags.ts rename to __tests__/slashtags.test.ts diff --git a/__tests__/todos.ts b/__tests__/todos.test.ts similarity index 100% rename from __tests__/todos.ts rename to __tests__/todos.test.ts diff --git a/__tests__/utils/dummy-wallet.ts b/__tests__/utils/dummy-wallet.ts deleted file mode 100644 index 19e0d3b90..000000000 --- a/__tests__/utils/dummy-wallet.ts +++ /dev/null @@ -1,4 +0,0 @@ -test.skip('Workaround', () => {}); - -export const mnemonic = - 'soon engine text scissors ready twelve paper raven merge skate north park broccoli acquire result broom ozone rigid huge taxi celery history sudden anchor'; diff --git a/__tests__/wallet.ts b/__tests__/wallet.test.ts similarity index 70% rename from __tests__/wallet.ts rename to __tests__/wallet.test.ts index ff8616f0b..59fb0ac53 100644 --- a/__tests__/wallet.ts +++ b/__tests__/wallet.test.ts @@ -1,9 +1,8 @@ import * as bip39 from 'bip39'; - -// Fix 'getDispatch is not a function' -import '../src/store/utils/ui'; import { slashtagsPrimaryKey } from '../src/utils/wallet'; -import { mnemonic } from './utils/dummy-wallet'; + +const mnemonic = + 'soon engine text scissors ready twelve paper raven merge skate north park broccoli acquire result broom ozone rigid huge taxi celery history sudden anchor'; describe('Wallet Methods', () => { it('Derive slashtags primay key from the Seed', async () => { diff --git a/jest.config.js b/jest.config.js index 00d20a678..a6431d9a0 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,7 @@ module.exports = { './node_modules/react-native-gesture-handler/jestSetup.js', 'dotenv/config', ], + testMatch: ["**/?(*.)+(spec|test).[jt]s?(x)"], moduleNameMapper: { '\\.(jpg|jpeg|svg|png)$': '/__mocks__/fileMock.js', }, diff --git a/src/utils/i18n/index.ts b/src/utils/i18n/index.ts index c51cdfc9c..b9592ad4c 100644 --- a/src/utils/i18n/index.ts +++ b/src/utils/i18n/index.ts @@ -3,7 +3,7 @@ import ICU from 'i18next-icu'; import { initReactI18next } from 'react-i18next'; import * as RNLocalize from 'react-native-localize'; -import { __ENABLE_I18NEXT_DEBUGGER__ } from '../../constants/env'; +import { __ENABLE_I18NEXT_DEBUGGER__, __JEST__ } from '../../constants/env'; import { dispatch } from '../../store/helpers'; import { updateUi } from '../../store/slices/ui'; import convert from './convert'; @@ -65,6 +65,10 @@ i18nICU dispatch(updateUi({ timeZone, language: i18nICU.language })); }) .then(async () => { + if (__JEST__) { + return; + } + // we need to load language related polyfill data const lang = i18nICU.language; try {