1- import { OnRampController , BlockchainApiController , ConstantsUtil } from '../../index' ;
1+ import {
2+ OnRampController ,
3+ BlockchainApiController ,
4+ ConstantsUtil ,
5+ CoreHelperUtil
6+ } from '../../index' ;
27import { StorageUtil } from '../../utils/StorageUtil' ;
38import type {
49 OnRampCountry ,
@@ -17,6 +22,7 @@ jest.mock('../../controllers/EventsController', () => ({
1722 sendEvent : jest . fn ( )
1823 }
1924} ) ) ;
25+
2026jest . mock ( '../../controllers/NetworkController' , ( ) => ( {
2127 NetworkController : {
2228 state : {
@@ -25,6 +31,15 @@ jest.mock('../../controllers/NetworkController', () => ({
2531 }
2632} ) ) ;
2733
34+ jest . mock ( '../../utils/CoreHelperUtil' , ( ) => ( {
35+ CoreHelperUtil : {
36+ getCountryFromTimezone : jest . fn ( ) ,
37+ getBlockchainApiUrl : jest . fn ( ) ,
38+ getApiUrl : jest . fn ( ) ,
39+ debounce : jest . fn ( )
40+ }
41+ } ) ) ;
42+
2843const mockCountry : OnRampCountry = {
2944 countryCode : 'US' ,
3045 flagImageUrl : 'https://flagcdn.com/w20/us.png' ,
@@ -214,16 +229,18 @@ describe('OnRampController', () => {
214229
215230 describe ( 'setSelectedCountry' , ( ) => {
216231 it ( 'should update country and currency' , async ( ) => {
217- // Mock API responses
218- ( StorageUtil . setOnRampPreferredCountry as jest . Mock ) . mockResolvedValue ( undefined ) ;
219- ( StorageUtil . setOnRampPreferredFiatCurrency as jest . Mock ) . mockResolvedValue ( undefined ) ;
232+ // Mock utils
233+ ( StorageUtil . getOnRampCountries as jest . Mock ) . mockResolvedValue ( [ ] ) ;
234+ ( StorageUtil . getOnRampPreferredCountry as jest . Mock ) . mockResolvedValue ( undefined ) ;
235+ ( StorageUtil . setOnRampCountries as jest . Mock ) . mockImplementation ( ( ) => Promise . resolve ( [ ] ) ) ;
236+ ( CoreHelperUtil . getCountryFromTimezone as jest . Mock ) . mockReturnValue ( 'US' ) ;
220237
221238 // Mock COUNTRY_CURRENCIES mapping
222239 const originalCountryCurrencies = ConstantsUtil . COUNTRY_CURRENCIES ;
223240 Object . defineProperty ( ConstantsUtil , 'COUNTRY_CURRENCIES' , {
224241 value : {
225242 US : 'USD' ,
226- AR : 'ARS' // Assuming mockCountry2 has ES country code
243+ AR : 'ARS'
227244 } ,
228245 configurable : true
229246 } ) ;
0 commit comments