2022-02-22 21:58:21 +01:00
import React from 'react' ;
import {
getSettingsRoutes ,
2022-04-06 22:27:08 +02:00
getNumberOfSettingsInSection ,
2022-02-22 21:58:21 +01:00
handleSettingsRefs ,
} from './settings-search' ;
const t = ( key ) => {
switch ( key ) {
case 'general' :
return 'General' ;
case 'currencyConversion' :
2022-08-08 21:01:38 +02:00
return 'Currency conversion' ;
2022-02-22 21:58:21 +01:00
case 'primaryCurrencySetting' :
2022-08-08 21:01:38 +02:00
return 'Primary currency' ;
2022-02-22 21:58:21 +01:00
case 'primaryCurrencySettingDescription' :
return 'Select native to prioritize displaying values in the native currency of the chain (e.g. ETH). Select Fiat to prioritize displaying values in your selected fiat currency.' ;
case 'currentLanguage' :
2022-08-08 21:01:38 +02:00
return 'Current language' ;
2022-02-22 21:58:21 +01:00
case 'accountIdenticon' :
2022-08-08 21:01:38 +02:00
return 'Current language"' ;
2022-02-22 21:58:21 +01:00
case 'hideZeroBalanceTokens' :
2022-08-08 21:01:38 +02:00
return 'Hide tokens without balance' ;
2022-02-22 21:58:21 +01:00
case 'advanced' :
return 'Advanced' ;
case 'stateLogs' :
2022-08-08 21:01:38 +02:00
return 'State logs' ;
2022-02-22 21:58:21 +01:00
case 'stateLogsDescription' :
return 'State logs contain your public account addresses and sent transactions.' ;
case 'syncWithMobile' :
return 'Sync with mobile' ;
case 'resetAccount' :
2022-08-08 21:01:38 +02:00
return 'Reset account' ;
2022-02-22 21:58:21 +01:00
case 'resetAccountDescription' :
return 'Resetting your account will clear your transaction history. This will not change the balances in your accounts or require you to re-enter your Secret Recovery Phrase.' ;
case 'showAdvancedGasInline' :
return 'Advanced gas controls' ;
case 'showAdvancedGasInlineDescription' :
return 'Select this to show gas price and limit controls directly on the send and confirm screens.' ;
case 'showHexData' :
2022-08-08 21:01:38 +02:00
return 'Show hex data' ;
2022-02-22 21:58:21 +01:00
case 'showHexDataDescription' :
return 'Select this to show the hex data field on the send screen' ;
case 'showFiatConversionInTestnets' :
2022-08-08 21:01:38 +02:00
return 'Show conversion on test networks' ;
2022-02-22 21:58:21 +01:00
case 'showFiatConversionInTestnetsDescription' :
return 'Select this to show fiat conversion on test network' ;
case 'showTestnetNetworks' :
return 'Show test networks' ;
case 'showTestnetNetworksDescription' :
return 'Select this to show test networks in network list' ;
case 'nonceField' :
return 'Customize transaction nonce' ;
case 'nonceFieldDescription' :
return 'Turn this on to change the nonce (transaction number) on confirmation screens. This is an advanced feature, use cautiously.' ;
case 'autoLockTimeLimit' :
2022-08-08 21:01:38 +02:00
return 'Auto-lock timer (minutes)' ;
2022-02-22 21:58:21 +01:00
case 'autoLockTimeLimitDescription' :
return 'Set the idle time in minutes before MetaMask will become locked.' ;
case 'ipfsGateway' :
return 'IPFS Gateway' ;
case 'ipfsGatewayDescription' :
return 'Enter the URL of the IPFS CID gateway to use for ENS content resolution.' ;
case 'preferredLedgerConnectionType' :
2022-08-08 21:01:38 +02:00
return 'Preferred ledger connection type' ;
2022-02-22 21:58:21 +01:00
case 'dismissReminderField' :
return 'Dismiss Secret Recovery Phrase backup reminder' ;
case 'dismissReminderDescriptionField' :
return 'Turn this on to dismiss the Secret Recovery Phrase backup reminder message. We highly recommend that you back up your Secret Recovery Phrase to avoid loss of funds' ;
case 'Contacts' :
return 'Contacts' ;
case 'securityAndPrivacy' :
2022-08-08 21:01:38 +02:00
return 'Security & privacy' ;
2022-02-22 21:58:21 +01:00
case 'revealSeedWords' :
return 'Reveal Secret Recovery Phrase' ;
case 'showIncomingTransactions' :
2022-08-08 21:01:38 +02:00
return 'Show incoming transactions' ;
2022-02-22 21:58:21 +01:00
case 'showIncomingTransactionsDescription' :
return 'Select this to use Etherscan to show incoming transactions in the transactions list' ;
case 'usePhishingDetection' :
2022-08-08 21:01:38 +02:00
return 'Use phishing detection' ;
2022-02-22 21:58:21 +01:00
case 'usePhishingDetectionDescription' :
return 'Display a warning for phishing domains targeting Ethereum users' ;
case 'participateInMetaMetrics' :
return 'Participate in MetaMetrics' ;
case 'participateInMetaMetricsDescription' :
return 'Participate in MetaMetrics to help us make MetaMask better' ;
case 'alerts' :
return 'Alerts' ;
case 'alertSettingsUnconnectedAccount' :
return 'Browsing a website with an unconnected account selected' ;
case 'alertSettingsWeb3ShimUsage' :
return 'When a website tries to use the removed window.web3 API' ;
case 'networks' :
return 'Networks' ;
case 'mainnet' :
return 'Ethereum Mainnet' ;
case 'goerli' :
2022-08-08 21:01:38 +02:00
return 'Goerli test network' ;
2022-09-14 20:26:45 +02:00
case 'sepolia' :
return 'Sepolia test network' ;
2022-02-22 21:58:21 +01:00
case 'localhost' :
return 'Localhost 8545' ;
case 'experimental' :
return 'Experimental' ;
2023-01-18 15:43:57 +01:00
case 'autoDetectTokens' :
return 'Autodetect tokens' ;
case 'autoDetectTokensDescription' :
return 'We use third-party APIs to detect and display new tokens sent to your wallet. Turn off if you don’ t want the app to pull data from those services.' ;
2022-02-22 21:58:21 +01:00
case 'enableOpenSeaAPI' :
return 'Enable OpenSea API' ;
case 'enableOpenSeaAPIDescription' :
2022-03-23 17:47:54 +01:00
return "Use OpenSea's API to fetch NFT data. NFT auto-detection relies on OpenSea's API, and will not be available when this is turned off." ;
2022-02-22 21:58:21 +01:00
case 'useCollectibleDetection' :
return 'Autodetect NFTs' ;
case 'useCollectibleDetectionDescription' :
return 'Displaying NFTs media & data may expose your IP address to centralized servers. Third-party APIs (like OpenSea) are used to detect NFTs in your wallet. This exposes your account address with those services. Leave this disabled if you don’ t want the app to pull data from those those services.' ;
case 'about' :
return 'About' ;
case 'metamaskVersion' :
return 'MetaMask Version' ;
case 'builtAroundTheWorld' :
return 'MetaMask is designed and built around the world.' ;
case 'links' :
return 'Links' ;
case 'privacyMsg' :
2022-08-08 21:01:38 +02:00
return 'Privacy policy' ;
2022-02-22 21:58:21 +01:00
case 'terms' :
2022-08-08 21:01:38 +02:00
return 'Terms of use' ;
2022-02-22 21:58:21 +01:00
case 'attributions' :
return 'Attributions' ;
case 'supportCenter' :
2022-08-08 21:01:38 +02:00
return 'Visit our support center' ;
2022-02-22 21:58:21 +01:00
case 'visitWebSite' :
return 'Visit our web site' ;
case 'contactUs' :
return 'Contact us' ;
2022-03-23 17:47:54 +01:00
case 'snaps' :
return 'Snaps' ;
2023-01-17 16:23:04 +01:00
case 'currencyRateCheckToggle' :
return 'Show balance and token price checker' ;
case 'currencyRateCheckToggleDescription' :
return 'We use Coingecko and CryptoCompare APIs to display your balance and token price. Privacy Policy' ;
2022-02-22 21:58:21 +01:00
default :
return '' ;
}
} ;
describe ( 'Settings Search Utils' , ( ) => {
2022-04-06 22:27:08 +02:00
describe ( 'settingsRoutes' , ( ) => {
it ( 'should be an array of settings routes objects' , ( ) => {
expect ( getSettingsRoutes ( ) . length ) . toBeGreaterThan ( 0 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
} ) ;
2022-04-06 22:27:08 +02:00
describe ( 'getNumberOfSettingsInSection' , ( ) => {
2022-02-22 21:58:21 +01:00
it ( 'should get good general section number' , ( ) => {
2022-09-23 17:15:02 +02:00
expect ( getNumberOfSettingsInSection ( t , t ( 'general' ) ) ) . toStrictEqual ( 6 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good advanced section number' , ( ) => {
2023-02-06 17:47:50 +01:00
expect ( getNumberOfSettingsInSection ( t , t ( 'advanced' ) ) ) . toStrictEqual ( 14 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good contact section number' , ( ) => {
2022-04-06 22:27:08 +02:00
expect ( getNumberOfSettingsInSection ( t , t ( 'contacts' ) ) ) . toStrictEqual ( 1 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good security & privacy section number' , ( ) => {
expect (
2022-04-06 22:27:08 +02:00
getNumberOfSettingsInSection ( t , t ( 'securityAndPrivacy' ) ) ,
2023-01-18 15:43:57 +01:00
) . toStrictEqual ( 9 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good alerts section number' , ( ) => {
2022-04-06 22:27:08 +02:00
expect ( getNumberOfSettingsInSection ( t , t ( 'alerts' ) ) ) . toStrictEqual ( 2 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good network section number' , ( ) => {
2022-09-29 05:26:01 +02:00
expect ( getNumberOfSettingsInSection ( t , t ( 'networks' ) ) ) . toStrictEqual ( 4 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good experimental section number' , ( ) => {
2022-04-06 22:27:08 +02:00
expect ( getNumberOfSettingsInSection ( t , t ( 'experimental' ) ) ) . toStrictEqual (
2023-01-23 17:19:55 +01:00
1 ,
2022-04-06 22:27:08 +02:00
) ;
2022-02-22 21:58:21 +01:00
} ) ;
it ( 'should get good about section number' , ( ) => {
2022-11-09 23:15:44 +01:00
expect ( getNumberOfSettingsInSection ( t , t ( 'about' ) ) ) . toStrictEqual ( 9 ) ;
2022-02-22 21:58:21 +01:00
} ) ;
} ) ;
// Can't be tested without DOM element
describe ( 'handleSettingsRefs' , ( ) => {
it ( 'should handle general refs' , ( ) => {
2022-04-06 22:27:08 +02:00
const settingsRefs = Array ( getNumberOfSettingsInSection ( t , t ( 'general' ) ) )
2022-02-22 21:58:21 +01:00
. fill ( undefined )
. map ( ( ) => {
return React . createRef ( ) ;
} ) ;
expect ( handleSettingsRefs ( t , t ( 'general' ) , settingsRefs ) ) . toBeUndefined ( ) ;
} ) ;
} ) ;
} ) ;