@spacesops/wdk-react-native-core 1.0.0-beta.40
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/README.md +551 -0
- package/dist/__mocks__/react.d.ts +40 -0
- package/dist/__mocks__/react.js +33 -0
- package/dist/__mocks__/react.js.map +1 -0
- package/dist/__mocks__/secureStorage.d.ts +26 -0
- package/dist/__mocks__/secureStorage.js +80 -0
- package/dist/__mocks__/secureStorage.js.map +1 -0
- package/dist/__tests__/hooks/useBalance.test.d.ts +6 -0
- package/dist/__tests__/hooks/useBalance.test.js +217 -0
- package/dist/__tests__/hooks/useBalance.test.js.map +1 -0
- package/dist/__tests__/hooks/useWallet.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWallet.test.js +105 -0
- package/dist/__tests__/hooks/useWallet.test.js.map +1 -0
- package/dist/__tests__/hooks/useWalletManager.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWalletManager.test.js +193 -0
- package/dist/__tests__/hooks/useWalletManager.test.js.map +1 -0
- package/dist/__tests__/hooks/useWdkApp.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWdkApp.test.js +55 -0
- package/dist/__tests__/hooks/useWdkApp.test.js.map +1 -0
- package/dist/__tests__/hooks/useWorklet.test.d.ts +6 -0
- package/dist/__tests__/hooks/useWorklet.test.js +168 -0
- package/dist/__tests__/hooks/useWorklet.test.js.map +1 -0
- package/dist/__tests__/provider/WdkAppProvider.test.d.ts +6 -0
- package/dist/__tests__/provider/WdkAppProvider.test.js +57 -0
- package/dist/__tests__/provider/WdkAppProvider.test.js.map +1 -0
- package/dist/__tests__/services/accountService.test.d.ts +6 -0
- package/dist/__tests__/services/accountService.test.js +216 -0
- package/dist/__tests__/services/accountService.test.js.map +1 -0
- package/dist/__tests__/services/addressService.test.d.ts +6 -0
- package/dist/__tests__/services/addressService.test.js +246 -0
- package/dist/__tests__/services/addressService.test.js.map +1 -0
- package/dist/__tests__/services/balanceService.test.d.ts +6 -0
- package/dist/__tests__/services/balanceService.test.js +333 -0
- package/dist/__tests__/services/balanceService.test.js.map +1 -0
- package/dist/__tests__/services/walletSetupService.test.d.ts +6 -0
- package/dist/__tests__/services/walletSetupService.test.js +304 -0
- package/dist/__tests__/services/walletSetupService.test.js.map +1 -0
- package/dist/__tests__/services/walletSwitchingService.test.d.ts +6 -0
- package/dist/__tests__/services/walletSwitchingService.test.js +209 -0
- package/dist/__tests__/services/walletSwitchingService.test.js.map +1 -0
- package/dist/__tests__/services/workletLifecycleService.test.d.ts +6 -0
- package/dist/__tests__/services/workletLifecycleService.test.js +451 -0
- package/dist/__tests__/services/workletLifecycleService.test.js.map +1 -0
- package/dist/__tests__/setup.d.ts +7 -0
- package/dist/__tests__/setup.js +49 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/storage/mmkvStorage.test.d.ts +6 -0
- package/dist/__tests__/storage/mmkvStorage.test.js +213 -0
- package/dist/__tests__/storage/mmkvStorage.test.js.map +1 -0
- package/dist/__tests__/store/walletStore.test.d.ts +4 -0
- package/dist/__tests__/store/walletStore.test.js +86 -0
- package/dist/__tests__/store/walletStore.test.js.map +1 -0
- package/dist/__tests__/store/workletStore.test.d.ts +4 -0
- package/dist/__tests__/store/workletStore.test.js +255 -0
- package/dist/__tests__/store/workletStore.test.js.map +1 -0
- package/dist/__tests__/types/hrpc.test.d.ts +4 -0
- package/dist/__tests__/types/hrpc.test.js +99 -0
- package/dist/__tests__/types/hrpc.test.js.map +1 -0
- package/dist/__tests__/utils/balanceUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/balanceUtils.test.js +133 -0
- package/dist/__tests__/utils/balanceUtils.test.js.map +1 -0
- package/dist/__tests__/utils/errorHandling.test.d.ts +6 -0
- package/dist/__tests__/utils/errorHandling.test.js +119 -0
- package/dist/__tests__/utils/errorHandling.test.js.map +1 -0
- package/dist/__tests__/utils/errorUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/errorUtils.test.js +133 -0
- package/dist/__tests__/utils/errorUtils.test.js.map +1 -0
- package/dist/__tests__/utils/initializationState.test.d.ts +6 -0
- package/dist/__tests__/utils/initializationState.test.js +243 -0
- package/dist/__tests__/utils/initializationState.test.js.map +1 -0
- package/dist/__tests__/utils/jsonUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/jsonUtils.test.js +118 -0
- package/dist/__tests__/utils/jsonUtils.test.js.map +1 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.d.ts +6 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.js +158 -0
- package/dist/__tests__/utils/mmkvKeyManager.test.js.map +1 -0
- package/dist/__tests__/utils/mnemonicUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/mnemonicUtils.test.js +40 -0
- package/dist/__tests__/utils/mnemonicUtils.test.js.map +1 -0
- package/dist/__tests__/utils/raceConditions.test.d.ts +6 -0
- package/dist/__tests__/utils/raceConditions.test.js +239 -0
- package/dist/__tests__/utils/raceConditions.test.js.map +1 -0
- package/dist/__tests__/utils/result.test.d.ts +4 -0
- package/dist/__tests__/utils/result.test.js +66 -0
- package/dist/__tests__/utils/result.test.js.map +1 -0
- package/dist/__tests__/utils/schemas.test.d.ts +4 -0
- package/dist/__tests__/utils/schemas.test.js +66 -0
- package/dist/__tests__/utils/schemas.test.js.map +1 -0
- package/dist/__tests__/utils/storeHelpers.test.d.ts +4 -0
- package/dist/__tests__/utils/storeHelpers.test.js +227 -0
- package/dist/__tests__/utils/storeHelpers.test.js.map +1 -0
- package/dist/__tests__/utils/typeGuards.test.d.ts +4 -0
- package/dist/__tests__/utils/typeGuards.test.js +175 -0
- package/dist/__tests__/utils/typeGuards.test.js.map +1 -0
- package/dist/__tests__/utils/validation.test.d.ts +4 -0
- package/dist/__tests__/utils/validation.test.js +126 -0
- package/dist/__tests__/utils/validation.test.js.map +1 -0
- package/dist/__tests__/utils/walletUtils.test.d.ts +4 -0
- package/dist/__tests__/utils/walletUtils.test.js +156 -0
- package/dist/__tests__/utils/walletUtils.test.js.map +1 -0
- package/dist/hooks/useBalance.d.ts +170 -0
- package/dist/hooks/useBalance.js +442 -0
- package/dist/hooks/useBalance.js.map +1 -0
- package/dist/hooks/useWallet.d.ts +43 -0
- package/dist/hooks/useWallet.js +193 -0
- package/dist/hooks/useWallet.js.map +1 -0
- package/dist/hooks/useWalletManager.d.ts +100 -0
- package/dist/hooks/useWalletManager.js +526 -0
- package/dist/hooks/useWalletManager.js.map +1 -0
- package/dist/hooks/useWdkApp.d.ts +66 -0
- package/dist/hooks/useWdkApp.js +74 -0
- package/dist/hooks/useWdkApp.js.map +1 -0
- package/dist/hooks/useWorklet.d.ts +66 -0
- package/dist/hooks/useWorklet.js +42 -0
- package/dist/hooks/useWorklet.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/WdkAppProvider.d.ts +112 -0
- package/dist/provider/WdkAppProvider.js +558 -0
- package/dist/provider/WdkAppProvider.js.map +1 -0
- package/dist/services/accountService.d.ts +52 -0
- package/dist/services/accountService.js +119 -0
- package/dist/services/accountService.js.map +1 -0
- package/dist/services/addressService.d.ts +22 -0
- package/dist/services/addressService.js +110 -0
- package/dist/services/addressService.js.map +1 -0
- package/dist/services/balanceService.d.ts +114 -0
- package/dist/services/balanceService.js +208 -0
- package/dist/services/balanceService.js.map +1 -0
- package/dist/services/walletSetupService.d.ts +217 -0
- package/dist/services/walletSetupService.js +535 -0
- package/dist/services/walletSetupService.js.map +1 -0
- package/dist/services/walletSwitchingService.d.ts +48 -0
- package/dist/services/walletSwitchingService.js +143 -0
- package/dist/services/walletSwitchingService.js.map +1 -0
- package/dist/services/workletLifecycleService.d.ts +117 -0
- package/dist/services/workletLifecycleService.js +433 -0
- package/dist/services/workletLifecycleService.js.map +1 -0
- package/dist/storage/mmkvStorage.d.ts +44 -0
- package/dist/storage/mmkvStorage.js +348 -0
- package/dist/storage/mmkvStorage.js.map +1 -0
- package/dist/store/walletStore.d.ts +130 -0
- package/dist/store/walletStore.js +204 -0
- package/dist/store/walletStore.js.map +1 -0
- package/dist/store/workletStore.d.ts +121 -0
- package/dist/store/workletStore.js +256 -0
- package/dist/store/workletStore.js.map +1 -0
- package/dist/types/hrpc.d.ts +60 -0
- package/dist/types/hrpc.js +26 -0
- package/dist/types/hrpc.js.map +1 -0
- package/dist/types.d.ts +168 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/balanceUtils.d.ts +30 -0
- package/dist/utils/balanceUtils.js +86 -0
- package/dist/utils/balanceUtils.js.map +1 -0
- package/dist/utils/constants.d.ts +66 -0
- package/dist/utils/constants.js +73 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/errorHandling.d.ts +47 -0
- package/dist/utils/errorHandling.js +54 -0
- package/dist/utils/errorHandling.js.map +1 -0
- package/dist/utils/errorUtils.d.ts +89 -0
- package/dist/utils/errorUtils.js +264 -0
- package/dist/utils/errorUtils.js.map +1 -0
- package/dist/utils/initializationState.d.ts +129 -0
- package/dist/utils/initializationState.js +220 -0
- package/dist/utils/initializationState.js.map +1 -0
- package/dist/utils/jsonUtils.d.ts +21 -0
- package/dist/utils/jsonUtils.js +67 -0
- package/dist/utils/jsonUtils.js.map +1 -0
- package/dist/utils/logger.d.ts +27 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mmkvKeyManager.d.ts +57 -0
- package/dist/utils/mmkvKeyManager.js +214 -0
- package/dist/utils/mmkvKeyManager.js.map +1 -0
- package/dist/utils/mnemonicUtils.d.ts +17 -0
- package/dist/utils/mnemonicUtils.js +28 -0
- package/dist/utils/mnemonicUtils.js.map +1 -0
- package/dist/utils/operationMutex.d.ts +69 -0
- package/dist/utils/operationMutex.js +150 -0
- package/dist/utils/operationMutex.js.map +1 -0
- package/dist/utils/result.d.ts +34 -0
- package/dist/utils/result.js +43 -0
- package/dist/utils/result.js.map +1 -0
- package/dist/utils/schemas.d.ts +365 -0
- package/dist/utils/schemas.js +152 -0
- package/dist/utils/schemas.js.map +1 -0
- package/dist/utils/storeHelpers.d.ts +112 -0
- package/dist/utils/storeHelpers.js +198 -0
- package/dist/utils/storeHelpers.js.map +1 -0
- package/dist/utils/typeGuards.d.ts +70 -0
- package/dist/utils/typeGuards.js +95 -0
- package/dist/utils/typeGuards.js.map +1 -0
- package/dist/utils/validation.d.ts +53 -0
- package/dist/utils/validation.js +152 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/walletStateHelpers.d.ts +62 -0
- package/dist/utils/walletStateHelpers.js +81 -0
- package/dist/utils/walletStateHelpers.js.map +1 -0
- package/dist/utils/walletUtils.d.ts +38 -0
- package/dist/utils/walletUtils.js +87 -0
- package/dist/utils/walletUtils.js.map +1 -0
- package/package.json +79 -0
- package/src/__mocks__/react.ts +34 -0
- package/src/__mocks__/secureStorage.ts +87 -0
- package/src/__tests__/hooks/useBalance.test.ts +286 -0
- package/src/__tests__/hooks/useWallet.test.ts +122 -0
- package/src/__tests__/hooks/useWalletManager.test.ts +271 -0
- package/src/__tests__/hooks/useWdkApp.test.tsx +59 -0
- package/src/__tests__/hooks/useWorklet.test.ts +195 -0
- package/src/__tests__/provider/WdkAppProvider.test.tsx +67 -0
- package/src/__tests__/services/accountService.test.ts +337 -0
- package/src/__tests__/services/addressService.test.ts +312 -0
- package/src/__tests__/services/balanceService.test.ts +411 -0
- package/src/__tests__/services/walletSetupService.test.ts +463 -0
- package/src/__tests__/services/walletSwitchingService.test.ts +258 -0
- package/src/__tests__/services/workletLifecycleService.test.ts +514 -0
- package/src/__tests__/setup.ts +54 -0
- package/src/__tests__/storage/mmkvStorage.test.ts +325 -0
- package/src/__tests__/store/walletStore.test.ts +101 -0
- package/src/__tests__/store/workletStore.test.ts +329 -0
- package/src/__tests__/types/hrpc.test.ts +125 -0
- package/src/__tests__/utils/balanceUtils.test.ts +151 -0
- package/src/__tests__/utils/errorHandling.test.ts +147 -0
- package/src/__tests__/utils/errorUtils.test.ts +170 -0
- package/src/__tests__/utils/initializationState.test.ts +337 -0
- package/src/__tests__/utils/jsonUtils.test.ts +131 -0
- package/src/__tests__/utils/mmkvKeyManager.test.ts +205 -0
- package/src/__tests__/utils/mnemonicUtils.test.ts +48 -0
- package/src/__tests__/utils/raceConditions.test.ts +292 -0
- package/src/__tests__/utils/result.test.ts +73 -0
- package/src/__tests__/utils/schemas.test.ts +82 -0
- package/src/__tests__/utils/storeHelpers.test.ts +323 -0
- package/src/__tests__/utils/typeGuards.test.ts +209 -0
- package/src/__tests__/utils/validation.test.ts +152 -0
- package/src/__tests__/utils/walletUtils.test.ts +195 -0
- package/src/hooks/useBalance.ts +597 -0
- package/src/hooks/useWallet.ts +288 -0
- package/src/hooks/useWalletManager.ts +654 -0
- package/src/hooks/useWdkApp.ts +78 -0
- package/src/hooks/useWorklet.ts +109 -0
- package/src/index.ts +112 -0
- package/src/provider/WdkAppProvider.tsx +764 -0
- package/src/services/accountService.ts +134 -0
- package/src/services/addressService.ts +125 -0
- package/src/services/balanceService.ts +291 -0
- package/src/services/walletSetupService.ts +695 -0
- package/src/services/walletSwitchingService.ts +157 -0
- package/src/services/workletLifecycleService.ts +561 -0
- package/src/storage/mmkvStorage.ts +417 -0
- package/src/store/walletStore.ts +301 -0
- package/src/store/workletStore.ts +340 -0
- package/src/types/hrpc.ts +78 -0
- package/src/types.ts +188 -0
- package/src/utils/balanceUtils.ts +96 -0
- package/src/utils/constants.ts +84 -0
- package/src/utils/errorHandling.md +163 -0
- package/src/utils/errorHandling.ts +61 -0
- package/src/utils/errorUtils.ts +300 -0
- package/src/utils/initializationState.ts +242 -0
- package/src/utils/jsonUtils.ts +75 -0
- package/src/utils/logger.ts +54 -0
- package/src/utils/mmkvKeyManager.ts +256 -0
- package/src/utils/mnemonicUtils.ts +35 -0
- package/src/utils/operationMutex.ts +181 -0
- package/src/utils/result.ts +57 -0
- package/src/utils/schemas.ts +190 -0
- package/src/utils/storeHelpers.ts +236 -0
- package/src/utils/typeGuards.ts +129 -0
- package/src/utils/validation.ts +174 -0
- package/src/utils/walletStateHelpers.ts +104 -0
- package/src/utils/walletUtils.ts +107 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for useWalletManager hook
|
|
3
|
+
*
|
|
4
|
+
* Tests wallet lifecycle management hook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { WalletSetupService } from '../../services/walletSetupService'
|
|
8
|
+
import { getWalletStore } from '../../store/walletStore'
|
|
9
|
+
import type { NetworkConfigs } from '../../types'
|
|
10
|
+
|
|
11
|
+
// Mock stores and services
|
|
12
|
+
jest.mock('../../store/walletStore', () => ({
|
|
13
|
+
getWalletStore: jest.fn(),
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
jest.mock('../../services/walletSetupService', () => ({
|
|
17
|
+
WalletSetupService: {
|
|
18
|
+
initializeWallet: jest.fn(),
|
|
19
|
+
hasWallet: jest.fn(),
|
|
20
|
+
initializeFromMnemonic: jest.fn(),
|
|
21
|
+
deleteWallet: jest.fn(),
|
|
22
|
+
getMnemonic: jest.fn(),
|
|
23
|
+
createNewWallet: jest.fn(),
|
|
24
|
+
},
|
|
25
|
+
}))
|
|
26
|
+
|
|
27
|
+
jest.mock('../../utils/logger', () => ({
|
|
28
|
+
log: jest.fn(),
|
|
29
|
+
logError: jest.fn(),
|
|
30
|
+
}))
|
|
31
|
+
|
|
32
|
+
// Mock React hooks
|
|
33
|
+
jest.mock('react', () => ({
|
|
34
|
+
useCallback: jest.fn((fn) => fn),
|
|
35
|
+
useMemo: jest.fn((fn) => fn()),
|
|
36
|
+
useState: jest.fn((initial) => [initial, jest.fn()]),
|
|
37
|
+
}))
|
|
38
|
+
|
|
39
|
+
jest.mock('zustand/react/shallow', () => ({
|
|
40
|
+
useShallow: jest.fn((selector) => selector),
|
|
41
|
+
}))
|
|
42
|
+
|
|
43
|
+
describe('useWalletManager', () => {
|
|
44
|
+
let mockWalletStore: any
|
|
45
|
+
const mockNetworkConfigs: NetworkConfigs = {
|
|
46
|
+
ethereum: {
|
|
47
|
+
chainId: 1,
|
|
48
|
+
blockchain: 'ethereum',
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
jest.clearAllMocks()
|
|
54
|
+
|
|
55
|
+
mockWalletStore = {
|
|
56
|
+
getState: jest.fn(() => ({
|
|
57
|
+
walletList: [],
|
|
58
|
+
activeWalletId: null,
|
|
59
|
+
})),
|
|
60
|
+
setState: jest.fn(),
|
|
61
|
+
}
|
|
62
|
+
;(getWalletStore as jest.Mock).mockReturnValue(mockWalletStore)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
describe('initializeWallet', () => {
|
|
66
|
+
it('should call WalletSetupService.initializeWallet', async () => {
|
|
67
|
+
;(WalletSetupService.initializeWallet as jest.Mock).mockResolvedValue(
|
|
68
|
+
undefined,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const { useWalletManager } = await import('../../hooks/useWalletManager')
|
|
72
|
+
|
|
73
|
+
// Since we can't easily test React hooks in Node, we verify the service calls
|
|
74
|
+
expect(WalletSetupService.initializeWallet).toBeDefined()
|
|
75
|
+
expect(typeof WalletSetupService.initializeWallet).toBe('function')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('should handle initialization errors', async () => {
|
|
79
|
+
const error = new Error('Initialization failed')
|
|
80
|
+
;(WalletSetupService.initializeWallet as jest.Mock).mockRejectedValue(
|
|
81
|
+
error,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
expect(WalletSetupService.initializeWallet).toBeDefined()
|
|
85
|
+
await expect(
|
|
86
|
+
WalletSetupService.initializeWallet(mockNetworkConfigs, {}),
|
|
87
|
+
).rejects.toThrow('Initialization failed')
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('initializeFromMnemonic', () => {
|
|
92
|
+
it('should call WalletSetupService.initializeFromMnemonic', async () => {
|
|
93
|
+
const mnemonic =
|
|
94
|
+
'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
|
|
95
|
+
;(
|
|
96
|
+
WalletSetupService.initializeFromMnemonic as jest.Mock
|
|
97
|
+
).mockResolvedValue(undefined)
|
|
98
|
+
|
|
99
|
+
expect(WalletSetupService.initializeFromMnemonic).toBeDefined()
|
|
100
|
+
await WalletSetupService.initializeFromMnemonic(
|
|
101
|
+
mockNetworkConfigs,
|
|
102
|
+
mnemonic,
|
|
103
|
+
'test-wallet',
|
|
104
|
+
)
|
|
105
|
+
expect(WalletSetupService.initializeFromMnemonic).toHaveBeenCalledWith(
|
|
106
|
+
mockNetworkConfigs,
|
|
107
|
+
mnemonic,
|
|
108
|
+
'test-wallet',
|
|
109
|
+
)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('should handle mnemonic import errors', async () => {
|
|
113
|
+
const error = new Error('Invalid mnemonic')
|
|
114
|
+
;(
|
|
115
|
+
WalletSetupService.initializeFromMnemonic as jest.Mock
|
|
116
|
+
).mockRejectedValue(error)
|
|
117
|
+
|
|
118
|
+
await expect(
|
|
119
|
+
WalletSetupService.initializeFromMnemonic(
|
|
120
|
+
mockNetworkConfigs,
|
|
121
|
+
'invalid',
|
|
122
|
+
'test-wallet',
|
|
123
|
+
),
|
|
124
|
+
).rejects.toThrow('Invalid mnemonic')
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
describe('hasWallet', () => {
|
|
129
|
+
it('should check if wallet exists', async () => {
|
|
130
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockResolvedValue(true)
|
|
131
|
+
|
|
132
|
+
const result = await WalletSetupService.hasWallet('test-wallet')
|
|
133
|
+
expect(result).toBe(true)
|
|
134
|
+
expect(WalletSetupService.hasWallet).toHaveBeenCalledWith('test-wallet')
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should return false if wallet does not exist', async () => {
|
|
138
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockResolvedValue(false)
|
|
139
|
+
|
|
140
|
+
const result = await WalletSetupService.hasWallet('non-existent')
|
|
141
|
+
expect(result).toBe(false)
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
describe('deleteWallet', () => {
|
|
146
|
+
it('should delete wallet and update store', async () => {
|
|
147
|
+
;(WalletSetupService.deleteWallet as jest.Mock).mockResolvedValue(
|
|
148
|
+
undefined,
|
|
149
|
+
)
|
|
150
|
+
mockWalletStore.getState.mockReturnValue({
|
|
151
|
+
walletList: [
|
|
152
|
+
{ identifier: 'test-wallet', exists: true, isActive: true },
|
|
153
|
+
],
|
|
154
|
+
activeWalletId: 'test-wallet',
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
await WalletSetupService.deleteWallet('test-wallet')
|
|
158
|
+
expect(WalletSetupService.deleteWallet).toHaveBeenCalledWith(
|
|
159
|
+
'test-wallet',
|
|
160
|
+
)
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('should handle delete errors', async () => {
|
|
164
|
+
const error = new Error('Delete failed')
|
|
165
|
+
;(WalletSetupService.deleteWallet as jest.Mock).mockRejectedValue(error)
|
|
166
|
+
|
|
167
|
+
await expect(
|
|
168
|
+
WalletSetupService.deleteWallet('test-wallet'),
|
|
169
|
+
).rejects.toThrow('Delete failed')
|
|
170
|
+
})
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
describe('getMnemonic', () => {
|
|
174
|
+
it('should retrieve mnemonic phrase', async () => {
|
|
175
|
+
const mnemonic =
|
|
176
|
+
'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
|
|
177
|
+
;(WalletSetupService.getMnemonic as jest.Mock).mockResolvedValue(mnemonic)
|
|
178
|
+
|
|
179
|
+
const result = await WalletSetupService.getMnemonic('test-wallet')
|
|
180
|
+
expect(result).toBe(mnemonic)
|
|
181
|
+
expect(WalletSetupService.getMnemonic).toHaveBeenCalledWith('test-wallet')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('should return null if mnemonic not found', async () => {
|
|
185
|
+
;(WalletSetupService.getMnemonic as jest.Mock).mockResolvedValue(null)
|
|
186
|
+
|
|
187
|
+
const result = await WalletSetupService.getMnemonic('non-existent')
|
|
188
|
+
expect(result).toBeNull()
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
it('should handle get mnemonic errors', async () => {
|
|
192
|
+
const error = new Error('Failed to get mnemonic')
|
|
193
|
+
;(WalletSetupService.getMnemonic as jest.Mock).mockRejectedValue(error)
|
|
194
|
+
|
|
195
|
+
await expect(
|
|
196
|
+
WalletSetupService.getMnemonic('test-wallet'),
|
|
197
|
+
).rejects.toThrow('Failed to get mnemonic')
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
describe('createWallet', () => {
|
|
202
|
+
it('should create new wallet', async () => {
|
|
203
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockResolvedValue(false)
|
|
204
|
+
;(WalletSetupService.createNewWallet as jest.Mock).mockResolvedValue(
|
|
205
|
+
undefined,
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
await WalletSetupService.createNewWallet(mockNetworkConfigs, 'new-wallet')
|
|
209
|
+
expect(WalletSetupService.createNewWallet).toHaveBeenCalledWith(
|
|
210
|
+
mockNetworkConfigs,
|
|
211
|
+
'new-wallet',
|
|
212
|
+
)
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
it('should throw error if wallet already exists', async () => {
|
|
216
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockResolvedValue(true)
|
|
217
|
+
|
|
218
|
+
// This would be handled in the hook, but we verify the service
|
|
219
|
+
expect(WalletSetupService.hasWallet).toBeDefined()
|
|
220
|
+
})
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
describe('refreshWalletList', () => {
|
|
224
|
+
it('should refresh wallet list with known identifiers', async () => {
|
|
225
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockImplementation((id) => {
|
|
226
|
+
return Promise.resolve(id === 'wallet-1' || id === 'wallet-2')
|
|
227
|
+
})
|
|
228
|
+
|
|
229
|
+
mockWalletStore.getState.mockReturnValue({
|
|
230
|
+
walletList: [],
|
|
231
|
+
activeWalletId: 'wallet-1',
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
// Verify hasWallet can be called for multiple wallets
|
|
235
|
+
const wallet1Exists = await WalletSetupService.hasWallet('wallet-1')
|
|
236
|
+
const wallet2Exists = await WalletSetupService.hasWallet('wallet-2')
|
|
237
|
+
const wallet3Exists = await WalletSetupService.hasWallet('wallet-3')
|
|
238
|
+
|
|
239
|
+
expect(wallet1Exists).toBe(true)
|
|
240
|
+
expect(wallet2Exists).toBe(true)
|
|
241
|
+
expect(wallet3Exists).toBe(false)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
it('should handle refresh errors', async () => {
|
|
245
|
+
const error = new Error('Refresh failed')
|
|
246
|
+
;(WalletSetupService.hasWallet as jest.Mock).mockRejectedValue(error)
|
|
247
|
+
|
|
248
|
+
await expect(WalletSetupService.hasWallet('test-wallet')).rejects.toThrow(
|
|
249
|
+
'Refresh failed',
|
|
250
|
+
)
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
describe('wallet list state', () => {
|
|
255
|
+
it('should return wallet list from store', () => {
|
|
256
|
+
const walletList = [
|
|
257
|
+
{ identifier: 'wallet-1', exists: true, isActive: true },
|
|
258
|
+
{ identifier: 'wallet-2', exists: true, isActive: false },
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
mockWalletStore.getState.mockReturnValue({
|
|
262
|
+
walletList,
|
|
263
|
+
activeWalletId: 'wallet-1',
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
const state = mockWalletStore.getState()
|
|
267
|
+
expect(state.walletList).toEqual(walletList)
|
|
268
|
+
expect(state.activeWalletId).toBe('wallet-1')
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
})
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for useWdkApp hook
|
|
3
|
+
*
|
|
4
|
+
* Tests hook logic without DOM rendering
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { WdkAppContextValue } from '../../provider/WdkAppProvider'
|
|
8
|
+
import { AppStatus, InitializationStatus } from '../../utils/initializationState'
|
|
9
|
+
|
|
10
|
+
describe('useWdkApp', () => {
|
|
11
|
+
it('should have correct error message when context is null', () => {
|
|
12
|
+
const errorMessage = 'useWdkApp must be used within WdkAppProvider'
|
|
13
|
+
expect(errorMessage).toBe('useWdkApp must be used within WdkAppProvider')
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('should validate context value structure', () => {
|
|
17
|
+
const mockContextValue: WdkAppContextValue = {
|
|
18
|
+
status: AppStatus.READY,
|
|
19
|
+
workletStatus: InitializationStatus.WORKLET_READY,
|
|
20
|
+
workletState: {
|
|
21
|
+
isReady: true,
|
|
22
|
+
isLoading: false,
|
|
23
|
+
error: null,
|
|
24
|
+
},
|
|
25
|
+
walletState: {
|
|
26
|
+
status: 'ready',
|
|
27
|
+
identifier: 'test-wallet',
|
|
28
|
+
error: null,
|
|
29
|
+
},
|
|
30
|
+
isInitializing: false,
|
|
31
|
+
isReady: true,
|
|
32
|
+
activeWalletId: 'test-wallet',
|
|
33
|
+
loadingWalletId: null,
|
|
34
|
+
walletExists: true,
|
|
35
|
+
error: null,
|
|
36
|
+
retry: jest.fn(),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Validate structure
|
|
40
|
+
expect(mockContextValue).toHaveProperty('status')
|
|
41
|
+
expect(mockContextValue).toHaveProperty('workletStatus')
|
|
42
|
+
expect(mockContextValue).toHaveProperty('workletState')
|
|
43
|
+
expect(mockContextValue).toHaveProperty('walletState')
|
|
44
|
+
expect(mockContextValue).toHaveProperty('isInitializing')
|
|
45
|
+
expect(mockContextValue).toHaveProperty('isReady')
|
|
46
|
+
expect(mockContextValue).toHaveProperty('activeWalletId')
|
|
47
|
+
expect(mockContextValue).toHaveProperty('loadingWalletId')
|
|
48
|
+
expect(mockContextValue).toHaveProperty('walletExists')
|
|
49
|
+
expect(mockContextValue).toHaveProperty('error')
|
|
50
|
+
expect(mockContextValue).toHaveProperty('retry')
|
|
51
|
+
expect(typeof mockContextValue.retry).toBe('function')
|
|
52
|
+
expect(mockContextValue.status).toBe(AppStatus.READY)
|
|
53
|
+
expect(mockContextValue.workletStatus).toBe(InitializationStatus.WORKLET_READY)
|
|
54
|
+
expect(mockContextValue.isReady).toBe(true)
|
|
55
|
+
expect(mockContextValue.workletState.isReady).toBe(true)
|
|
56
|
+
expect(mockContextValue.walletState.status).toBe('ready')
|
|
57
|
+
expect(mockContextValue.activeWalletId).toBe('test-wallet')
|
|
58
|
+
})
|
|
59
|
+
})
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for useWorklet hook
|
|
3
|
+
*
|
|
4
|
+
* Tests worklet interaction hook
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { WorkletLifecycleService } from '../../services/workletLifecycleService'
|
|
8
|
+
import { getWorkletStore } from '../../store/workletStore'
|
|
9
|
+
|
|
10
|
+
// Mock stores and services
|
|
11
|
+
jest.mock('../../store/workletStore', () => ({
|
|
12
|
+
getWorkletStore: jest.fn(),
|
|
13
|
+
}))
|
|
14
|
+
|
|
15
|
+
jest.mock('../../services/workletLifecycleService', () => ({
|
|
16
|
+
WorkletLifecycleService: {
|
|
17
|
+
initializeWDK: jest.fn(),
|
|
18
|
+
generateEntropyAndEncrypt: jest.fn(),
|
|
19
|
+
getMnemonicFromEntropy: jest.fn(),
|
|
20
|
+
getSeedAndEntropyFromMnemonic: jest.fn(),
|
|
21
|
+
initializeWorklet: jest.fn(),
|
|
22
|
+
reset: jest.fn(),
|
|
23
|
+
clearError: jest.fn(),
|
|
24
|
+
},
|
|
25
|
+
}))
|
|
26
|
+
|
|
27
|
+
// Mock React hooks
|
|
28
|
+
jest.mock('zustand/react/shallow', () => ({
|
|
29
|
+
useShallow: jest.fn((selector) => selector),
|
|
30
|
+
}))
|
|
31
|
+
|
|
32
|
+
describe('useWorklet', () => {
|
|
33
|
+
let mockWorkletStore: any
|
|
34
|
+
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
jest.clearAllMocks()
|
|
37
|
+
|
|
38
|
+
mockWorkletStore = jest.fn((selector: any) => {
|
|
39
|
+
const state = {
|
|
40
|
+
isWorkletStarted: true,
|
|
41
|
+
isInitialized: true,
|
|
42
|
+
isLoading: false,
|
|
43
|
+
error: null,
|
|
44
|
+
hrpc: null,
|
|
45
|
+
worklet: null,
|
|
46
|
+
workletStartResult: null,
|
|
47
|
+
wdkInitResult: null,
|
|
48
|
+
encryptedSeed: null,
|
|
49
|
+
encryptionKey: null,
|
|
50
|
+
networkConfigs: null,
|
|
51
|
+
}
|
|
52
|
+
return selector ? selector(state) : state
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
;(getWorkletStore as jest.Mock).mockReturnValue(mockWorkletStore)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
describe('state subscription', () => {
|
|
59
|
+
it('should subscribe to worklet store state', () => {
|
|
60
|
+
const store = getWorkletStore()
|
|
61
|
+
const state = store((s: any) => s)
|
|
62
|
+
|
|
63
|
+
expect(state).toBeDefined()
|
|
64
|
+
expect(state.isWorkletStarted).toBe(true)
|
|
65
|
+
expect(state.isInitialized).toBe(true)
|
|
66
|
+
expect(state.isLoading).toBe(false)
|
|
67
|
+
expect(state.error).toBeNull()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('should return all state properties', () => {
|
|
71
|
+
const store = getWorkletStore()
|
|
72
|
+
const state = store((s: any) => ({
|
|
73
|
+
isWorkletStarted: s.isWorkletStarted,
|
|
74
|
+
isInitialized: s.isInitialized,
|
|
75
|
+
isLoading: s.isLoading,
|
|
76
|
+
error: s.error,
|
|
77
|
+
hrpc: s.hrpc,
|
|
78
|
+
worklet: s.worklet,
|
|
79
|
+
workletStartResult: s.workletStartResult,
|
|
80
|
+
wdkInitResult: s.wdkInitResult,
|
|
81
|
+
encryptedSeed: s.encryptedSeed,
|
|
82
|
+
encryptionKey: s.encryptionKey,
|
|
83
|
+
networkConfigs: s.networkConfigs,
|
|
84
|
+
}))
|
|
85
|
+
|
|
86
|
+
expect(state).toHaveProperty('isWorkletStarted')
|
|
87
|
+
expect(state).toHaveProperty('isInitialized')
|
|
88
|
+
expect(state).toHaveProperty('isLoading')
|
|
89
|
+
expect(state).toHaveProperty('error')
|
|
90
|
+
expect(state).toHaveProperty('hrpc')
|
|
91
|
+
expect(state).toHaveProperty('worklet')
|
|
92
|
+
expect(state).toHaveProperty('workletStartResult')
|
|
93
|
+
expect(state).toHaveProperty('wdkInitResult')
|
|
94
|
+
expect(state).toHaveProperty('encryptedSeed')
|
|
95
|
+
expect(state).toHaveProperty('encryptionKey')
|
|
96
|
+
expect(state).toHaveProperty('networkConfigs')
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
describe('service method delegation', () => {
|
|
101
|
+
it('should delegate initializeWDK to WorkletLifecycleService', () => {
|
|
102
|
+
expect(WorkletLifecycleService.initializeWDK).toBeDefined()
|
|
103
|
+
expect(typeof WorkletLifecycleService.initializeWDK).toBe('function')
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it('should delegate generateEntropyAndEncrypt to WorkletLifecycleService', () => {
|
|
107
|
+
expect(WorkletLifecycleService.generateEntropyAndEncrypt).toBeDefined()
|
|
108
|
+
expect(typeof WorkletLifecycleService.generateEntropyAndEncrypt).toBe('function')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('should delegate getMnemonicFromEntropy to WorkletLifecycleService', () => {
|
|
112
|
+
expect(WorkletLifecycleService.getMnemonicFromEntropy).toBeDefined()
|
|
113
|
+
expect(typeof WorkletLifecycleService.getMnemonicFromEntropy).toBe('function')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('should delegate getSeedAndEntropyFromMnemonic to WorkletLifecycleService', () => {
|
|
117
|
+
expect(WorkletLifecycleService.getSeedAndEntropyFromMnemonic).toBeDefined()
|
|
118
|
+
expect(typeof WorkletLifecycleService.getSeedAndEntropyFromMnemonic).toBe('function')
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
it('should delegate initializeWorklet to WorkletLifecycleService', () => {
|
|
122
|
+
expect(WorkletLifecycleService.initializeWorklet).toBeDefined()
|
|
123
|
+
expect(typeof WorkletLifecycleService.initializeWorklet).toBe('function')
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
it('should delegate reset to WorkletLifecycleService', () => {
|
|
127
|
+
expect(WorkletLifecycleService.reset).toBeDefined()
|
|
128
|
+
expect(typeof WorkletLifecycleService.reset).toBe('function')
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('should delegate clearError to WorkletLifecycleService', () => {
|
|
132
|
+
expect(WorkletLifecycleService.clearError).toBeDefined()
|
|
133
|
+
expect(typeof WorkletLifecycleService.clearError).toBe('function')
|
|
134
|
+
})
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
describe('error state', () => {
|
|
138
|
+
it('should handle error state', () => {
|
|
139
|
+
mockWorkletStore = jest.fn((selector: any) => {
|
|
140
|
+
const state = {
|
|
141
|
+
isWorkletStarted: false,
|
|
142
|
+
isInitialized: false,
|
|
143
|
+
isLoading: false,
|
|
144
|
+
error: 'Worklet initialization failed',
|
|
145
|
+
hrpc: null,
|
|
146
|
+
worklet: null,
|
|
147
|
+
workletStartResult: null,
|
|
148
|
+
wdkInitResult: null,
|
|
149
|
+
encryptedSeed: null,
|
|
150
|
+
encryptionKey: null,
|
|
151
|
+
networkConfigs: null,
|
|
152
|
+
}
|
|
153
|
+
return selector ? selector(state) : state
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
;(getWorkletStore as jest.Mock).mockReturnValue(mockWorkletStore)
|
|
157
|
+
|
|
158
|
+
const store = getWorkletStore()
|
|
159
|
+
const state = store((s: any) => s)
|
|
160
|
+
|
|
161
|
+
expect(state.error).toBe('Worklet initialization failed')
|
|
162
|
+
expect(state.isInitialized).toBe(false)
|
|
163
|
+
})
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
describe('loading state', () => {
|
|
167
|
+
it('should handle loading state', () => {
|
|
168
|
+
mockWorkletStore = jest.fn((selector: any) => {
|
|
169
|
+
const state = {
|
|
170
|
+
isWorkletStarted: false,
|
|
171
|
+
isInitialized: false,
|
|
172
|
+
isLoading: true,
|
|
173
|
+
error: null,
|
|
174
|
+
hrpc: null,
|
|
175
|
+
worklet: null,
|
|
176
|
+
workletStartResult: null,
|
|
177
|
+
wdkInitResult: null,
|
|
178
|
+
encryptedSeed: null,
|
|
179
|
+
encryptionKey: null,
|
|
180
|
+
networkConfigs: null,
|
|
181
|
+
}
|
|
182
|
+
return selector ? selector(state) : state
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
;(getWorkletStore as jest.Mock).mockReturnValue(mockWorkletStore)
|
|
186
|
+
|
|
187
|
+
const store = getWorkletStore()
|
|
188
|
+
const state = store((s: any) => s)
|
|
189
|
+
|
|
190
|
+
expect(state.isLoading).toBe(true)
|
|
191
|
+
expect(state.isInitialized).toBe(false)
|
|
192
|
+
})
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for WdkAppProvider
|
|
3
|
+
*
|
|
4
|
+
* Tests validation logic without rendering DOM components
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { validateNetworkConfigs, validateTokenConfigs, validateBalanceRefreshInterval } from '../../utils/validation'
|
|
8
|
+
import type { NetworkConfigs, TokenConfigs } from '../../types'
|
|
9
|
+
import { mockSecureStorage } from '../../__mocks__/secureStorage'
|
|
10
|
+
|
|
11
|
+
describe('WdkAppProvider validation', () => {
|
|
12
|
+
const mockNetworkConfigs: NetworkConfigs = {
|
|
13
|
+
ethereum: {
|
|
14
|
+
chainId: 1,
|
|
15
|
+
blockchain: 'ethereum',
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const mockTokenConfigs: TokenConfigs = {
|
|
20
|
+
ethereum: {
|
|
21
|
+
native: {
|
|
22
|
+
symbol: 'ETH',
|
|
23
|
+
name: 'Ethereum',
|
|
24
|
+
decimals: 18,
|
|
25
|
+
address: null,
|
|
26
|
+
},
|
|
27
|
+
tokens: [],
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
it('should validate networkConfigs', () => {
|
|
32
|
+
expect(() => validateNetworkConfigs(mockNetworkConfigs)).not.toThrow()
|
|
33
|
+
expect(() => validateNetworkConfigs({} as NetworkConfigs)).toThrow()
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('should validate tokenConfigs', () => {
|
|
37
|
+
expect(() => validateTokenConfigs(mockTokenConfigs)).not.toThrow()
|
|
38
|
+
expect(() => validateTokenConfigs({} as TokenConfigs)).toThrow()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should validate balanceRefreshInterval', () => {
|
|
42
|
+
expect(() => validateBalanceRefreshInterval(30000)).not.toThrow()
|
|
43
|
+
expect(() => validateBalanceRefreshInterval(0)).not.toThrow()
|
|
44
|
+
expect(() => validateBalanceRefreshInterval(-1)).toThrow()
|
|
45
|
+
expect(() => validateBalanceRefreshInterval(NaN)).toThrow()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('should validate secureStorage has required methods', () => {
|
|
49
|
+
const requiredMethods = ['authenticate', 'hasWallet', 'setEncryptionKey', 'setEncryptedSeed', 'getAllEncrypted']
|
|
50
|
+
|
|
51
|
+
for (const method of requiredMethods) {
|
|
52
|
+
expect(typeof mockSecureStorage[method as keyof typeof mockSecureStorage]).toBe('function')
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('should detect missing secureStorage methods', () => {
|
|
57
|
+
const invalidStorage = {
|
|
58
|
+
authenticate: jest.fn(),
|
|
59
|
+
// Missing other methods
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const requiredMethods = ['hasWallet', 'setEncryptionKey', 'setEncryptedSeed', 'getAllEncrypted']
|
|
63
|
+
for (const method of requiredMethods) {
|
|
64
|
+
expect(typeof (invalidStorage as any)[method]).not.toBe('function')
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
})
|