@luxexchange/lx 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -14
- package/src/components/CurrencyInputPanel/AmountInputPresets/PresetAmountButton.tsx +1 -1
- package/src/components/CurrencyInputPanel/CurrencyInputPanelBalance.tsx +1 -1
- package/src/components/CurrencyInputPanel/CurrencyInputPanelHeader.tsx +1 -1
- package/src/components/CurrencyInputPanel/hooks/useIndicativeQuoteTextDisplay.ts +1 -1
- package/src/components/CurrencyLogo/TokenLogo.test.tsx +1 -1
- package/src/components/MultichainTokenDetails/MultichainAddressList.test.tsx +1 -1
- package/src/components/TokenSelector/filter.test.ts +1 -1
- package/src/components/TokenSelector/hooks/useLuxTokensOptions.ts +1 -1
- package/src/components/lists/OnchainItemList/processSectionsToRows.test.tsx +1 -1
- package/src/components/modals/WarningModal/types.ts +1 -1
- package/src/components/notifications/iconUtils.ts +1 -1
- package/src/components/reporting/ReportPoolDataModal.tsx +1 -1
- package/src/components/reporting/ReportTokenDataModal.tsx +1 -1
- package/src/components/reporting/ReportTokenIssueModal.tsx +1 -1
- package/src/constants/routing.ts +1 -1
- package/src/dialog-preferences/implementations/createDialogPreferencesService.test.ts +1 -1
- package/src/features/activity/extract/extractRestDEXOrderDetails.ts +1 -1
- package/src/features/activity/utils/remote.ts +1 -1
- package/src/features/chains/evm/info/avalanche.ts +1 -1
- package/src/features/chains/evm/info/blast.ts +1 -1
- package/src/features/chains/evm/info/bnb.ts +1 -1
- package/src/features/chains/evm/info/mainnet.ts +1 -1
- package/src/features/chains/evm/info/monad.ts +1 -1
- package/src/features/chains/evm/info/worldchain.ts +1 -1
- package/src/features/chains/evm/tokens.test.ts +1 -1
- package/src/features/chains/evm/tokens.ts +1 -1
- package/src/features/chains/utils.ts +1 -1
- package/src/features/dataApi/balances/balancesRest.ts +1 -1
- package/src/features/dataApi/balances/utils.ts +1 -1
- package/src/features/dataApi/types.ts +1 -1
- package/src/features/dataApi/utils/buildCurrency.test.ts +1 -1
- package/src/features/dataApi/utils/buildCurrency.ts +1 -1
- package/src/features/fiatOnRamp/PaymentMethodFilter/PaymentMethodFilter.test.tsx +1 -1
- package/src/features/fiatOnRamp/types.ts +1 -1
- package/src/features/gas/hooks/useCancellationGasFeeInfo.test.ts +1 -1
- package/src/features/gas/hooks/useMaxAmountSpend.ts +1 -1
- package/src/features/gas/utils.test.ts +1 -1
- package/src/features/language/formatter.ts +1 -1
- package/src/features/notifications/slice/types.ts +1 -1
- package/src/features/portfolio/portfolioUpdates/fetchOnChainBalances.ts +1 -1
- package/src/features/portfolio/portfolioUpdates/rest/fetchOnChainBalancesRest.test.ts +1 -1
- package/src/features/portfolio/portfolioUpdates/rest/fetchOnChainBalancesRest.ts +1 -1
- package/src/features/portfolio/portfolioUpdates/rest/refetchRestQueriesViaOnchainOverrideVariantSaga.test.ts +1 -1
- package/src/features/providers/FlashbotsRpcClient.test.ts +1 -1
- package/src/features/reporting/reports.ts +1 -1
- package/src/features/search/SearchModal/analytics/analytics.test.ts +1 -1
- package/src/features/settings/hooks.test.ts +2 -2
- package/src/features/tokens/SolanaToken.ts +1 -1
- package/src/features/tokens/getCurrencyAmount.test.ts +1 -1
- package/src/features/tokens/getCurrencyAmount.ts +1 -1
- package/src/features/tokens/stablecoin.ts +1 -1
- package/src/features/tokens/warnings/safetyUtils.test.ts +1 -1
- package/src/features/tokens/warnings/safetyUtils.ts +1 -1
- package/src/features/tokens/warnings/slice/hooks.ts +1 -1
- package/src/features/transactions/TransactionDetails/UserReceiveAmount.tsx +1 -1
- package/src/features/transactions/TransactionDetails/types.ts +1 -1
- package/src/features/transactions/cancel/cancelMultipleOrders.test.ts +1 -1
- package/src/features/transactions/cancel/cancelOrderFactory.test.ts +1 -1
- package/src/features/transactions/components/TransactionModal/TransactionModalContext.tsx +1 -1
- package/src/features/transactions/hooks/useUSDCPrice.ts +1 -1
- package/src/features/transactions/liquidity/steps/generateLPTransactionSteps.ts +1 -1
- package/src/features/transactions/steps/approve.ts +1 -1
- package/src/features/transactions/steps/permit2Transaction.ts +1 -1
- package/src/features/transactions/steps/wrap.ts +1 -1
- package/src/features/transactions/swap/components/MaxSlippageRow/SlippageInfo/SlippageInfoCaption.tsx +1 -1
- package/src/features/transactions/swap/components/MaxSlippageRow/SlippageInfo/useFormatSlippageAmount.ts +1 -1
- package/src/features/transactions/swap/components/PriceImpactRow/usePriceImpact.test.ts +1 -1
- package/src/features/transactions/swap/components/PriceImpactRow/usePriceImpact.ts +1 -1
- package/src/features/transactions/swap/components/SwapFormButton/hooks/useSwapFormButtonHooks.test.ts +1 -1
- package/src/features/transactions/swap/components/SwapFormSettings/settingsConfigurations/slippage/SlippageScreenNative.tsx +1 -1
- package/src/features/transactions/swap/components/UnichainInstantBalanceModal/hooks/receiptFetching/utils.ts +1 -1
- package/src/features/transactions/swap/form/SwapFormScreen/YouReceiveDetails/SwapDetailsRow.tsx +1 -1
- package/src/features/transactions/swap/form/hooks/useOnSelectCurrency.ts +1 -1
- package/src/features/transactions/swap/form/stores/swapFormScreenStore/createSwapFormScreenStore.ts +1 -1
- package/src/features/transactions/swap/form/stores/swapFormScreenStore/useSwapFormScreenCallbacks.test.ts +3 -3
- package/src/features/transactions/swap/hooks/useSwapWarnings/getBalanceWarning.test.ts +2 -2
- package/src/features/transactions/swap/hooks/useSwapWarnings/getFormIncompleteWarning.test.ts +1 -1
- package/src/features/transactions/swap/hooks/useSwapWarnings/getPriceImpactWarning.test.ts +1 -1
- package/src/features/transactions/swap/hooks/useSwapWarnings/getPriceImpactWarning.ts +1 -1
- package/src/features/transactions/swap/hooks/useSwapWarnings/getTokenBlockedWarning.test.ts +1 -1
- package/src/features/transactions/swap/hooks/useSwapWarnings/useSwapWarnings.test.ts +1 -1
- package/src/features/transactions/swap/hooks/useTrade/logging.ts +1 -1
- package/src/features/transactions/swap/hooks/useTrade/parseQuoteCurrencies.ts +1 -1
- package/src/features/transactions/swap/hooks/useTrade.ts +1 -1
- package/src/features/transactions/swap/plan/planSaga.test.ts +1 -1
- package/src/features/transactions/swap/review/hooks/useTokenApprovalInfo.test.ts +1 -1
- package/src/features/transactions/swap/review/services/swapTxAndGasInfoService/utils.test.ts +3 -3
- package/src/features/transactions/swap/services/tradeService/transformations/transformQuoteToTrade.ts +1 -1
- package/src/features/transactions/swap/types/derivedSwapInfo.ts +1 -1
- package/src/features/transactions/swap/types/getTradingApiSwapFee.test.ts +1 -1
- package/src/features/transactions/swap/types/getTradingApiSwapFee.ts +1 -1
- package/src/features/transactions/swap/types/solana.test.ts +1 -1
- package/src/features/transactions/swap/types/solana.ts +1 -1
- package/src/features/transactions/swap/types/trade.test.ts +1 -1
- package/src/features/transactions/swap/types/wrapCallback.ts +1 -1
- package/src/features/transactions/swap/utils/asset.ts +1 -1
- package/src/features/transactions/swap/utils/format.ts +1 -1
- package/src/features/transactions/swap/utils/formatPriceImpact.test.ts +1 -1
- package/src/features/transactions/swap/utils/formatPriceImpact.ts +1 -1
- package/src/features/transactions/swap/utils/generateSwapTransactionSteps.test.ts +2 -2
- package/src/features/transactions/swap/utils/getExactOutputWillFail.test.ts +1 -1
- package/src/features/transactions/swap/utils/getExactOutputWillFail.ts +1 -1
- package/src/features/transactions/swap/utils/getPriceImpact.ts +1 -1
- package/src/features/transactions/swap/utils/getSwapFeeUsd.ts +1 -1
- package/src/features/transactions/swap/utils/getTradeAmounts.ts +1 -1
- package/src/features/transactions/swap/utils/trade.test.ts +2 -2
- package/src/features/transactions/swap/utils/tradingApi.ts +3 -3
- package/src/features/transactions/swap/utils/wrap.ts +1 -1
- package/src/features/transactions/types/baseDerivedInfo.ts +1 -1
- package/src/features/unitags/UnitagInfoModal.tsx +1 -1
- package/src/i18n/utils.test.ts +1 -1
- package/src/test/fixtures/gql/assets/tokens.ts +1 -1
- package/src/test/fixtures/lib/sdk.ts +1 -1
- package/src/test/fixtures/transactions/swap.ts +2 -2
- package/src/test/fixtures/wallet/currencies.ts +1 -1
- package/src/test/fixtures/wallet/transactions/fixtures.ts +1 -1
- package/src/test/mocks/locale.ts +1 -1
- package/src/utils/approvals.test.ts +1 -1
- package/src/utils/currency.ts +1 -1
- package/src/utils/isWSOL.test.ts +1 -1
- package/src/utils/isWSOL.ts +1 -1
- package/src/utils/routingDiagram/routingProviders/jupiterRoutingProvider.test.ts +1 -1
- package/src/utils/routingDiagram/routingProviders/jupiterRoutingProvider.ts +1 -1
- package/src/utils/routingDiagram/routingProviders/luxRoutingProvider.test.ts +3 -3
- package/src/utils/routingDiagram/types.ts +1 -1
- package/src/utils/search/doesTokenMatchSearchTerm.test.ts +1 -1
- package/src/utils/search/doesTokenMatchSearchTerm.ts +1 -1
- package/.depcheckrc +0 -26
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -79
- package/LLM.md +0 -145
- package/babel.config.js +0 -39
- package/env.d.ts +0 -15
- package/eslint_rules/i18n.js +0 -44
- package/eslint_rules/no-redux-modals.js +0 -54
- package/jest-package-mocks.js +0 -38
- package/openapitools.json +0 -7
- package/tsconfig.eslint.json +0 -6
- package/vitest-package-mocks.ts +0 -76
- package/vitest-setup.ts +0 -246
- package/vitest.config.ts +0 -86
package/vitest-setup.ts
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest'
|
|
2
|
-
|
|
3
|
-
// Mock IntersectionObserver which is not available in jsdom
|
|
4
|
-
class MockIntersectionObserver {
|
|
5
|
-
readonly root: Element | null = null
|
|
6
|
-
readonly rootMargin: string = ''
|
|
7
|
-
readonly thresholds: ReadonlyArray<number> = []
|
|
8
|
-
|
|
9
|
-
constructor(
|
|
10
|
-
private callback: IntersectionObserverCallback,
|
|
11
|
-
private options?: IntersectionObserverInit,
|
|
12
|
-
) {}
|
|
13
|
-
|
|
14
|
-
observe(): void {}
|
|
15
|
-
unobserve(): void {}
|
|
16
|
-
disconnect(): void {}
|
|
17
|
-
takeRecords(): IntersectionObserverEntry[] {
|
|
18
|
-
return []
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
global.IntersectionObserver = MockIntersectionObserver as unknown as typeof IntersectionObserver
|
|
22
|
-
|
|
23
|
-
// Mock @testing-library/react-native to use @testing-library/react in jsdom environment
|
|
24
|
-
// This is necessary because @testing-library/react-native requires React Native runtime
|
|
25
|
-
vi.mock('@testing-library/react-native', async () => {
|
|
26
|
-
const rtl = await import('@testing-library/react')
|
|
27
|
-
|
|
28
|
-
// Create fireEvent as a function that also has methods (React Native style)
|
|
29
|
-
// React Native Testing Library supports: fireEvent(element, eventName, data)
|
|
30
|
-
// biome-ignore lint/suspicious/noExplicitAny: matching React Native Testing Library's fireEvent signature
|
|
31
|
-
const fireEventBase = (element: Element, eventName: string, data?: any): boolean => {
|
|
32
|
-
// Handle common React Native event names
|
|
33
|
-
const eventMap: Record<string, string> = {
|
|
34
|
-
press: 'click',
|
|
35
|
-
onPress: 'click',
|
|
36
|
-
longPress: 'contextmenu',
|
|
37
|
-
contextMenu: 'contextmenu',
|
|
38
|
-
onMouseDown: 'mousedown',
|
|
39
|
-
mouseDown: 'mousedown',
|
|
40
|
-
}
|
|
41
|
-
const webEventName = eventMap[eventName] || eventName
|
|
42
|
-
// biome-ignore lint/suspicious/noExplicitAny: matching React Native Testing Library's fireEvent signature
|
|
43
|
-
const fireEventFn = (rtl.fireEvent as any)[webEventName] || rtl.fireEvent
|
|
44
|
-
return fireEventFn(element, data)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Create fireEvent with both function call and method access
|
|
48
|
-
const fireEvent = Object.assign(fireEventBase, {
|
|
49
|
-
...rtl.fireEvent,
|
|
50
|
-
// Map press to click for web
|
|
51
|
-
press: (element: Element, options?: object) => rtl.fireEvent.click(element, options),
|
|
52
|
-
changeText: (element: Element, text: string) => rtl.fireEvent.change(element, { target: { value: text } }),
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
// Wrap render to add toJSON method for React Native Testing Library compatibility
|
|
56
|
-
// React Native Testing Library's toJSON() returns ReactTestRendererJSON from react-test-renderer
|
|
57
|
-
// Web's asFragment() returns DocumentFragment - both work with vitest snapshot serializers
|
|
58
|
-
// biome-ignore lint/suspicious/noExplicitAny: wrapping RTL render requires flexible types
|
|
59
|
-
const render = (...args: any[]) => {
|
|
60
|
-
const result = rtl.render(...args)
|
|
61
|
-
return {
|
|
62
|
-
...result,
|
|
63
|
-
// Map toJSON to asFragment for snapshot compatibility
|
|
64
|
-
toJSON: () => result.asFragment(),
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
...rtl,
|
|
70
|
-
render,
|
|
71
|
-
fireEvent,
|
|
72
|
-
// React Native specific exports that need mapping
|
|
73
|
-
cleanup: rtl.cleanup,
|
|
74
|
-
cleanupAsync: async () => rtl.cleanup(),
|
|
75
|
-
}
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
// Mock @testing-library/jest-native which requires React Native runtime
|
|
79
|
-
// This provides custom matchers for React Native that aren't needed in jsdom
|
|
80
|
-
vi.mock('@testing-library/jest-native', () => ({}))
|
|
81
|
-
|
|
82
|
-
// Mock expo-secure-store before any imports that might use it
|
|
83
|
-
vi.mock('expo-secure-store', () => ({
|
|
84
|
-
getItemAsync: vi.fn(() => Promise.resolve(null)),
|
|
85
|
-
setItemAsync: vi.fn(() => Promise.resolve()),
|
|
86
|
-
deleteItemAsync: vi.fn(() => Promise.resolve()),
|
|
87
|
-
}))
|
|
88
|
-
|
|
89
|
-
// Import shared mocks using relative paths
|
|
90
|
-
import '../../config/vitest-presets/vitest/setup.js'
|
|
91
|
-
import '../utilities/vitest-package-mocks'
|
|
92
|
-
import './vitest-package-mocks'
|
|
93
|
-
|
|
94
|
-
// Import from ui vitest-setup for React Native component mocks
|
|
95
|
-
import '../ui/vitest-setup'
|
|
96
|
-
|
|
97
|
-
// Mock i18n to avoid require() path resolution issues
|
|
98
|
-
// The original jest setup imported 'lx/src/i18n' but that uses require() internally
|
|
99
|
-
// Common translations map for test assertions that look for translated text
|
|
100
|
-
const commonTranslations: Record<string, string> = {
|
|
101
|
-
'common.button.retry': 'Retry',
|
|
102
|
-
'common.error.title': 'Oops! Something went wrong.',
|
|
103
|
-
'common.card.error.title': 'Oops! Something went wrong.',
|
|
104
|
-
'common.card.error.description': 'Something went wrong.',
|
|
105
|
-
'common.button.learn': 'Learn more',
|
|
106
|
-
'common.text.learnMore': 'Learn more',
|
|
107
|
-
'unitags.claim.error.unavailable': 'Username unavailable',
|
|
108
|
-
'common.today': 'Today',
|
|
109
|
-
'common.yesterday': 'Yesterday',
|
|
110
|
-
// Storage settings translations
|
|
111
|
-
'settings.setting.storage.clearAccountHistory.title': 'Clear account history',
|
|
112
|
-
'settings.setting.storage.clearAccountHistory.subtitle': 'Clear your account history',
|
|
113
|
-
'settings.setting.storage.clearUserSettings.title': 'Clear preferences',
|
|
114
|
-
'settings.setting.storage.clearUserSettings.subtitle': 'Clear your preferences',
|
|
115
|
-
'settings.setting.storage.clearCachedData.title': 'Clear cache',
|
|
116
|
-
'settings.setting.storage.clearCachedData.subtitle': 'Clear cached data',
|
|
117
|
-
'settings.setting.storage.clearAllData.title': 'Clear all data',
|
|
118
|
-
'settings.setting.storage.clearAllData.subtitle': 'Clear all local data',
|
|
119
|
-
'settings.setting.storage.confirm.approve': 'Clear data',
|
|
120
|
-
'settings.setting.storage.confirm.caption': 'Are you sure you want to clear this data?',
|
|
121
|
-
'settings.setting.storage.success': 'Data cleared successfully',
|
|
122
|
-
'settings.setting.storage.error': 'Failed to clear data',
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const mockT = (key: string, options?: Record<string, unknown>) => {
|
|
126
|
-
// Return common translations if available, otherwise return key
|
|
127
|
-
if (key in commonTranslations) {
|
|
128
|
-
return commonTranslations[key]
|
|
129
|
-
}
|
|
130
|
-
// Handle interpolation for keys with values
|
|
131
|
-
if (options && typeof options === 'object') {
|
|
132
|
-
let result = key
|
|
133
|
-
Object.entries(options).forEach(([k, v]) => {
|
|
134
|
-
result = result.replace(`{{${k}}}`, String(v))
|
|
135
|
-
})
|
|
136
|
-
return result
|
|
137
|
-
}
|
|
138
|
-
return key
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Mock react-i18next to provide translations for tests
|
|
142
|
-
vi.mock('react-i18next', () => ({
|
|
143
|
-
useTranslation: () => ({
|
|
144
|
-
t: mockT,
|
|
145
|
-
i18n: {
|
|
146
|
-
language: 'en',
|
|
147
|
-
changeLanguage: vi.fn(),
|
|
148
|
-
resolvedLanguage: 'en',
|
|
149
|
-
},
|
|
150
|
-
}),
|
|
151
|
-
Trans: ({ children }: { children?: React.ReactNode }) => children,
|
|
152
|
-
initReactI18next: { type: '3rdParty', init: vi.fn() },
|
|
153
|
-
}))
|
|
154
|
-
|
|
155
|
-
vi.mock('lx/src/i18n', () => ({
|
|
156
|
-
changeLanguage: vi.fn(),
|
|
157
|
-
default: {
|
|
158
|
-
t: (key: string, options?: Record<string, unknown>) => {
|
|
159
|
-
// Return common translations if available, otherwise return key
|
|
160
|
-
if (key in commonTranslations) {
|
|
161
|
-
return commonTranslations[key]
|
|
162
|
-
}
|
|
163
|
-
// Handle interpolation for keys with values
|
|
164
|
-
if (options && typeof options === 'object') {
|
|
165
|
-
let result = key
|
|
166
|
-
Object.entries(options).forEach(([k, v]) => {
|
|
167
|
-
result = result.replace(`{{${k}}}`, String(v))
|
|
168
|
-
})
|
|
169
|
-
return result
|
|
170
|
-
}
|
|
171
|
-
return key
|
|
172
|
-
},
|
|
173
|
-
exists: () => true,
|
|
174
|
-
language: 'en',
|
|
175
|
-
languages: ['en'],
|
|
176
|
-
resolvedLanguage: 'en',
|
|
177
|
-
changeLanguage: vi.fn(),
|
|
178
|
-
use: vi.fn().mockReturnThis(),
|
|
179
|
-
init: vi.fn().mockReturnThis(),
|
|
180
|
-
on: vi.fn(),
|
|
181
|
-
off: vi.fn(),
|
|
182
|
-
},
|
|
183
|
-
}))
|
|
184
|
-
|
|
185
|
-
vi.mock('lx/src/i18n/i18n-setup', () => ({}))
|
|
186
|
-
|
|
187
|
-
vi.mock(
|
|
188
|
-
'lx/src/features/transactions/components/settings/stores/transactionSettingsStore/useTransactionSettingsStore',
|
|
189
|
-
() => {
|
|
190
|
-
return {
|
|
191
|
-
useTransactionSettingsStore: (
|
|
192
|
-
selector: (state: { customDeadline: number; customSlippageTolerance: number }) => unknown,
|
|
193
|
-
) =>
|
|
194
|
-
selector({
|
|
195
|
-
customDeadline: 20,
|
|
196
|
-
customSlippageTolerance: 0.5,
|
|
197
|
-
}),
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
// Mock Modal component - provide simple implementations for tests
|
|
203
|
-
vi.mock('lx/src/components/modals/Modal', () => {
|
|
204
|
-
const React = require('react')
|
|
205
|
-
return {
|
|
206
|
-
Modal: ({ children, isModalOpen = true }: { children?: React.ReactNode; isModalOpen?: boolean }) => {
|
|
207
|
-
if (!isModalOpen) {
|
|
208
|
-
return null
|
|
209
|
-
}
|
|
210
|
-
return React.createElement('div', { 'data-testid': 'modal' }, children)
|
|
211
|
-
},
|
|
212
|
-
BottomSheetDetachedModal: ({ children }: { children?: React.ReactNode }) => {
|
|
213
|
-
return React.createElement('div', { 'data-testid': 'bottom-sheet-detached-modal' }, children)
|
|
214
|
-
},
|
|
215
|
-
BottomSheetTextInput: (props: Record<string, unknown>) => {
|
|
216
|
-
return React.createElement('input', props)
|
|
217
|
-
},
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
// Mock the browser's performance API
|
|
222
|
-
global.performance = require('perf_hooks').performance
|
|
223
|
-
|
|
224
|
-
// Mock calculateElapsedTimeWithPerformanceMarkMs with web implementation
|
|
225
|
-
vi.mock('@luxfi/utilities/src/telemetry/trace/utils/calculateElapsedTimeWithPerformanceMarkMs', () => ({
|
|
226
|
-
calculateElapsedTimeWithPerformanceMarkMs: (markName: string, fallbackStartTime?: number): number | undefined => {
|
|
227
|
-
const elapsedTime = performance.mark(markName)
|
|
228
|
-
if (elapsedTime) {
|
|
229
|
-
return elapsedTime.startTime
|
|
230
|
-
}
|
|
231
|
-
if (fallbackStartTime) {
|
|
232
|
-
return Date.now() - fallbackStartTime
|
|
233
|
-
}
|
|
234
|
-
return undefined
|
|
235
|
-
},
|
|
236
|
-
}))
|
|
237
|
-
|
|
238
|
-
// Mock OverKeyboardContent with web implementation
|
|
239
|
-
vi.mock('ui/src/components/OverKeyboardContent/OverKeyboardContent', () => {
|
|
240
|
-
const React = require('react')
|
|
241
|
-
return {
|
|
242
|
-
OverKeyboardContent: ({ visible, children }: { visible?: boolean; children?: React.ReactNode }) => {
|
|
243
|
-
return visible ? React.createElement(React.Fragment, null, children) : null
|
|
244
|
-
},
|
|
245
|
-
}
|
|
246
|
-
})
|
package/vitest.config.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import react from '@vitejs/plugin-react'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import { defineConfig } from 'vitest/config'
|
|
4
|
-
import vitestPreset from 'vitest-presets/vitest/vitest-preset.js'
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
...vitestPreset,
|
|
8
|
-
plugins: [react()],
|
|
9
|
-
test: {
|
|
10
|
-
...vitestPreset.test,
|
|
11
|
-
pool: 'forks',
|
|
12
|
-
globals: true,
|
|
13
|
-
environment: 'jsdom',
|
|
14
|
-
// Override the preset's jsdom customExportConditions to avoid loading React Native modules
|
|
15
|
-
environmentOptions: {
|
|
16
|
-
jsdom: {
|
|
17
|
-
// Don't use react-native export conditions - use default web exports
|
|
18
|
-
customExportConditions: [],
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
setupFiles: ['./vitest-setup.ts'],
|
|
22
|
-
include: ['src/**/*.test.ts', 'src/**/*.test.tsx'],
|
|
23
|
-
exclude: ['node_modules', 'dist', 'src/**/*.stories.**', 'src/abis/**'],
|
|
24
|
-
testTimeout: 15000,
|
|
25
|
-
deps: {
|
|
26
|
-
inline: [
|
|
27
|
-
/ui\/src\/theme/,
|
|
28
|
-
/packages\/ui/,
|
|
29
|
-
/packages\/utilities/,
|
|
30
|
-
/packages\/lux/,
|
|
31
|
-
/gui/,
|
|
32
|
-
/@testing-library\/react-native/,
|
|
33
|
-
/@react-navigation\/core/,
|
|
34
|
-
/@react-navigation\/native/,
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
server: {
|
|
38
|
-
deps: {
|
|
39
|
-
inline: [
|
|
40
|
-
/ui\/src\/theme/,
|
|
41
|
-
/packages\/ui/,
|
|
42
|
-
/packages\/utilities/,
|
|
43
|
-
/gui/,
|
|
44
|
-
/@testing-library\/react-native/,
|
|
45
|
-
/@react-navigation\/core/,
|
|
46
|
-
/@react-navigation\/native/,
|
|
47
|
-
],
|
|
48
|
-
fallbackCJS: true,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
reporters: ['verbose'],
|
|
52
|
-
coverage: {
|
|
53
|
-
include: ['src/**/*.{js,ts,tsx}'],
|
|
54
|
-
exclude: ['src/**/*.d.ts', 'src/**/*.stories.**', 'src/abis/**', '**/node_modules/**'],
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
define: {
|
|
58
|
-
__DEV__: true,
|
|
59
|
-
},
|
|
60
|
-
resolve: {
|
|
61
|
-
...vitestPreset.resolve,
|
|
62
|
-
extensions: ['.web.ts', '.web.tsx', '.ts', '.tsx', '.js', '.jsx', '.json'],
|
|
63
|
-
alias: {
|
|
64
|
-
'lux/src': path.resolve(__dirname, './src'),
|
|
65
|
-
'ui/src': path.resolve(__dirname, '../ui/src'),
|
|
66
|
-
'@luxfi/utilities/src': path.resolve(__dirname, '../utilities/src'),
|
|
67
|
-
|
|
68
|
-
// React Native aliases for testing
|
|
69
|
-
'react-native': 'react-native-web',
|
|
70
|
-
'react-native-gesture-handler': path.resolve(__dirname, '../../node_modules/react-native-gesture-handler'),
|
|
71
|
-
'@hanzogui/core': path.resolve(__dirname, '../../node_modules/@hanzogui/core/dist/cjs/index.cjs'),
|
|
72
|
-
'@hanzogui/web': path.resolve(__dirname, '../../node_modules/@hanzogui/web/dist/cjs/index.cjs'),
|
|
73
|
-
'@hanzogui/use-direction': path.resolve(__dirname, '../../node_modules/@hanzogui/use-direction/dist/cjs/index.cjs'),
|
|
74
|
-
'@hanzogui/use-callback-ref': path.resolve(
|
|
75
|
-
__dirname,
|
|
76
|
-
'../../node_modules/@hanzogui/use-callback-ref/dist/cjs/index.cjs',
|
|
77
|
-
),
|
|
78
|
-
'gui/linear-gradient': path.resolve(__dirname, '../../node_modules/gui/dist/cjs/linear-gradient.cjs'),
|
|
79
|
-
gui: path.resolve(__dirname, '../../node_modules/gui/dist/cjs/index.cjs'),
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
optimizeDeps: {
|
|
83
|
-
...vitestPreset.optimizeDeps,
|
|
84
|
-
include: ['react-native-web', '@testing-library/react-native'],
|
|
85
|
-
},
|
|
86
|
-
})
|