diff --git a/app/components/UI/AddCustomCollectible/index.js b/app/components/UI/AddCustomCollectible/index.js index 3a677b17a2a..8b3020f27da 100644 --- a/app/components/UI/AddCustomCollectible/index.js +++ b/app/components/UI/AddCustomCollectible/index.js @@ -10,7 +10,7 @@ import { isSmartContractAddress } from '../../../util/transactions'; import Device from '../../../util/Device'; import { connect } from 'react-redux'; import AnalyticsV2 from '../../../util/analyticsV2'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -169,7 +169,7 @@ class AddCustomCollectible extends PureComponent { const { selectedAddress } = this.props; try { const owner = await AssetsContractController.getOwnerOf(address, tokenId); - return toLowerCaseCompare(owner, selectedAddress); + return toLowerCaseEquals(owner, selectedAddress); } catch (e) { return false; } diff --git a/app/components/UI/AssetSearch/index.js b/app/components/UI/AssetSearch/index.js index 105c9eb410c..6cd4ddf0575 100644 --- a/app/components/UI/AssetSearch/index.js +++ b/app/components/UI/AssetSearch/index.js @@ -6,7 +6,7 @@ import { strings } from '../../../../locales/i18n'; import contractMap from '@metamask/contract-metadata'; import Fuse from 'fuse.js'; import Icon from 'react-native-vector-icons/FontAwesome'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ searchSection: { @@ -68,7 +68,7 @@ export default class AssetSearch extends PureComponent { handleSearch = searchQuery => { this.setState({ searchQuery }); const fuseSearchResult = fuse.search(searchQuery); - const addressSearchResult = contractList.filter(token => toLowerCaseCompare(token.address, searchQuery)); + const addressSearchResult = contractList.filter(token => toLowerCaseEquals(token.address, searchQuery)); const results = [...addressSearchResult, ...fuseSearchResult]; this.props.onSearch({ searchQuery, results }); }; diff --git a/app/components/UI/CollectibleContractOverview/index.js b/app/components/UI/CollectibleContractOverview/index.js index 0bbccd26b94..a718e0f7557 100644 --- a/app/components/UI/CollectibleContractOverview/index.js +++ b/app/components/UI/CollectibleContractOverview/index.js @@ -10,7 +10,7 @@ import { toggleCollectibleContractModal } from '../../../actions/modals'; import { connect } from 'react-redux'; import collectiblesTransferInformation from '../../../util/collectibles-transfer'; import { newAssetTransaction } from '../../../actions/transaction'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -86,7 +86,7 @@ class CollectibleContractOverview extends PureComponent { onSend = () => { const { collectibleContract, collectibles } = this.props; const collectible = collectibles.find(collectible => - toLowerCaseCompare(collectible.address, collectibleContract.address) + toLowerCaseEquals(collectible.address, collectibleContract.address) ); this.props.newAssetTransaction(collectible); this.props.navigation.navigate('SendFlowView'); diff --git a/app/components/UI/CollectibleContracts/index.js b/app/components/UI/CollectibleContracts/index.js index a5ef8d107bd..b4b0b8371c5 100644 --- a/app/components/UI/CollectibleContracts/index.js +++ b/app/components/UI/CollectibleContracts/index.js @@ -12,7 +12,7 @@ import CollectibleModal from '../CollectibleModal'; import { favoritesCollectiblesObjectSelector } from '../../../reducers/collectibles'; import Text from '../../Base/Text'; import AppConstants from '../../../core/AppConstants'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -97,7 +97,7 @@ const CollectibleContracts = ({ collectibleContracts, collectibles, navigation, const renderCollectibleContract = useCallback( (item, index) => { const contractCollectibles = collectibles?.filter(collectible => - toLowerCaseCompare(collectible.address, item.address) + toLowerCaseEquals(collectible.address, item.address) ); return ( - toLowerCaseCompare(collectible.address, transaction.selectedAsset.address) + toLowerCaseEquals(collectible.address, transaction.selectedAsset.address) ); this.setState({ assets: collectiblesToShow diff --git a/app/components/UI/PaymentRequest/index.js b/app/components/UI/PaymentRequest/index.js index b47d6e56849..e80ae8b75d7 100644 --- a/app/components/UI/PaymentRequest/index.js +++ b/app/components/UI/PaymentRequest/index.js @@ -39,7 +39,7 @@ import Device from '../../../util/Device'; import currencySymbols from '../../../util/currency-symbols.json'; import { NetworksChainId } from '@metamask/controllers'; import { getTicker } from '../../../util/transactions'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const KEYBOARD_OFFSET = 120; const styles = StyleSheet.create({ @@ -343,7 +343,7 @@ class PaymentRequest extends PureComponent { } const fuseSearchResult = fuse.search(searchInputValue); - const addressSearchResult = contractList.filter(token => toLowerCaseCompare(token.address, searchInputValue)); + const addressSearchResult = contractList.filter(token => toLowerCaseEquals(token.address, searchInputValue)); const results = [...addressSearchResult, ...fuseSearchResult]; this.setState({ searchInputValue, results }); }; diff --git a/app/components/UI/Swaps/QuotesView.js b/app/components/UI/Swaps/QuotesView.js index c45332d0b53..5485acfad28 100644 --- a/app/components/UI/Swaps/QuotesView.js +++ b/app/components/UI/Swaps/QuotesView.js @@ -52,7 +52,7 @@ import useBalance from './utils/useBalance'; import useGasPrice from './utils/useGasPrice'; import { trackErrorAsAnalytics } from '../../../util/analyticsV2'; import { decodeApproveData, getTicker } from '../../../util/transactions'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; import { swapsTokensSelector } from '../../../reducers/swaps'; const POLLING_INTERVAL = AppConstants.SWAPS.POLLING_INTERVAL; @@ -294,8 +294,8 @@ function SwapsQuotesView({ ); /* Get tokens from the tokens list */ - const sourceToken = swapsTokens?.find(token => toLowerCaseCompare(token.address, sourceTokenAddress)); - const destinationToken = swapsTokens?.find(token => toLowerCaseCompare(token.address, destinationTokenAddress)); + const sourceToken = swapsTokens?.find(token => toLowerCaseEquals(token.address, sourceTokenAddress)); + const destinationToken = swapsTokens?.find(token => toLowerCaseEquals(token.address, destinationTokenAddress)); const hasConversionRate = Boolean(destinationToken) && diff --git a/app/components/UI/Swaps/index.js b/app/components/UI/Swaps/index.js index b588880f08b..80fe38e9c8a 100644 --- a/app/components/UI/Swaps/index.js +++ b/app/components/UI/Swaps/index.js @@ -49,7 +49,7 @@ import SlippageModal from './components/SlippageModal'; import useBalance from './utils/useBalance'; import useBlockExplorer from './utils/useBlockExplorer'; import InfoModal from './components/InfoModal'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ screen: { @@ -161,11 +161,11 @@ function SwapsAmountView({ const [isInitialLoadingTokens, setInitialLoadingTokens] = useState(false); const [, setLoadingTokens] = useState(false); const [isSourceSet, setIsSourceSet] = useState(() => - Boolean(swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource))) + Boolean(swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource))) ); const [sourceToken, setSourceToken] = useState(() => - swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource)) + swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource)) ); const [destinationToken, setDestinationToken] = useState(null); const [hasDismissedTokenAlert, setHasDismissedTokenAlert] = useState(true); @@ -192,7 +192,7 @@ function SwapsAmountView({ InteractionManager.runAfterInteractions(() => { const parameters = { source: initialSource === SWAPS_NATIVE_ADDRESS ? 'MainView' : 'TokenView', - activeCurrency: swapsTokens?.find(token => toLowerCaseCompare(token.address, initialSource)) + activeCurrency: swapsTokens?.find(token => toLowerCaseEquals(token.address, initialSource)) ?.symbol, chain_id: chainId }; @@ -248,7 +248,7 @@ function SwapsAmountView({ useEffect(() => { if (!isSourceSet && initialSource && swapsTokens && !sourceToken) { setIsSourceSet(true); - setSourceToken(swapsTokens.find(token => toLowerCaseCompare(token.address, initialSource))); + setSourceToken(swapsTokens.find(token => toLowerCaseEquals(token.address, initialSource))); } }, [initialSource, isSourceSet, sourceToken, swapsTokens]); diff --git a/app/components/UI/TransactionEditor/index.js b/app/components/UI/TransactionEditor/index.js index f2d29595224..083240bcac9 100644 --- a/app/components/UI/TransactionEditor/index.js +++ b/app/components/UI/TransactionEditor/index.js @@ -18,7 +18,7 @@ import contractMap from '@metamask/contract-metadata'; import { safeToChecksumAddress } from '../../../util/address'; import TransactionTypes from '../../../core/TransactionTypes'; import { MAINNET } from '../../../constants/network'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const EDIT = 'edit'; const REVIEW = 'review'; @@ -381,7 +381,7 @@ class TransactionEditor extends PureComponent { const { selectedAddress } = this.props; try { const owner = await AssetsContractController.getOwnerOf(address, tokenId); - const isOwner = toLowerCaseCompare(owner, selectedAddress); + const isOwner = toLowerCaseEquals(owner, selectedAddress); if (!isOwner) { return strings('transaction.invalid_collectible_ownership'); } diff --git a/app/components/UI/TransactionElement/utils.js b/app/components/UI/TransactionElement/utils.js index 1838e9f1561..e032fc139e8 100644 --- a/app/components/UI/TransactionElement/utils.js +++ b/app/components/UI/TransactionElement/utils.js @@ -25,7 +25,7 @@ import contractMap from '@metamask/contract-metadata'; import { toChecksumAddress } from 'ethereumjs-util'; import { swapsUtils } from '@metamask/swaps-controller'; import { isSwapsNativeAsset } from '../Swaps/utils'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const { getSwapsContractAddress } = swapsUtils; @@ -139,7 +139,7 @@ function getCollectibleTransfer(args) { let actionKey; const [, tokenId] = decodeTransferData('transfer', data); const ticker = getTicker(args.ticker); - const collectible = collectibleContracts.find(collectible => toLowerCaseCompare(collectible.address, to)); + const collectible = collectibleContracts.find(collectible => toLowerCaseEquals(collectible.address, to)); if (collectible) { actionKey = `${strings('transactions.sent')} ${collectible.name}`; } else { @@ -335,7 +335,7 @@ function decodeTransferFromTx(args) { selectedAddress } = args; const [addressFrom, addressTo, tokenId] = decodeTransferData('transferFrom', data); - const collectible = collectibleContracts.find(collectible => toLowerCaseCompare(collectible.address, to)); + const collectible = collectibleContracts.find(collectible => toLowerCaseEquals(collectible.address, to)); let actionKey = args.actionKey; if (collectible) { actionKey = `${strings('transactions.sent')} ${collectible.name}`; diff --git a/app/components/Views/Asset/index.js b/app/components/Views/Asset/index.js index ec163be4a2b..4bf712c8bc3 100644 --- a/app/components/Views/Asset/index.js +++ b/app/components/Views/Asset/index.js @@ -11,7 +11,7 @@ import { getNetworkNavbarOptions } from '../../UI/Navbar'; import Engine from '../../../core/Engine'; import { safeToChecksumAddress } from '../../../util/address'; import { addAccountTimeFlagFilter } from '../../../util/transactions'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -146,7 +146,7 @@ class Asset extends PureComponent { ) { if (isTransfer) return this.props.tokens.find(({ address }) => - toLowerCaseCompare(address, transferInformation.contractAddress) + toLowerCaseEquals(address, transferInformation.contractAddress) ); return true; } diff --git a/app/components/Views/Collectible/index.js b/app/components/Views/Collectible/index.js index f246be613ca..24014ae0f5a 100644 --- a/app/components/Views/Collectible/index.js +++ b/app/components/Views/Collectible/index.js @@ -10,7 +10,7 @@ import Engine from '../../../core/Engine'; import Modal from 'react-native-modal'; import CollectibleContractInformation from '../../UI/CollectibleContractInformation'; import { toggleCollectibleContractModal } from '../../../actions/modals'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -76,7 +76,7 @@ class Collectible extends PureComponent { const address = params.address; const { collectibles } = this.props; const filteredCollectibles = collectibles.filter(collectible => - toLowerCaseCompare(collectible.address, address) + toLowerCaseEquals(collectible.address, address) ); filteredCollectibles.map(collectible => { if (!collectible.name || collectible.name === '') { diff --git a/app/components/Views/Login/index.js b/app/components/Views/Login/index.js index f3acf154739..c317b78af09 100644 --- a/app/components/Views/Login/index.js +++ b/app/components/Views/Login/index.js @@ -44,7 +44,7 @@ import ErrorBoundary from '../ErrorBoundary'; import WarningExistingUserModal from '../../UI/WarningExistingUserModal'; import Icon from 'react-native-vector-icons/FontAwesome'; import { trackErrorAsAnalytics } from '../../../util/analyticsV2'; -import { tlc, toLowerCaseCompare } from '../../../util/general'; +import { tlc, toLowerCaseEquals } from '../../../util/general'; const isTextDelete = text => tlc(text) === 'delete'; const deviceHeight = Device.getDeviceHeight(); @@ -314,8 +314,8 @@ class Login extends PureComponent { // Should we force people to enable passcode / biometrics? const error = e.toString(); if ( - toLowerCaseCompare(error, WRONG_PASSWORD_ERROR) || - toLowerCaseCompare(error, WRONG_PASSWORD_ERROR_ANDROID) + toLowerCaseEquals(error, WRONG_PASSWORD_ERROR) || + toLowerCaseEquals(error, WRONG_PASSWORD_ERROR_ANDROID) ) { this.setState({ loading: false, error: strings('login.invalid_password') }); @@ -328,7 +328,7 @@ class Login extends PureComponent { 'In order to proceed, you need to turn Passcode on or any biometrics authentication method supported in your device (FaceID, TouchID or Fingerprint)' ); this.setState({ loading: false }); - } else if (toLowerCaseCompare(error, VAULT_ERROR)) { + } else if (toLowerCaseEquals(error, VAULT_ERROR)) { this.setState({ loading: false, error: CLEAN_VAULT_ERROR diff --git a/app/components/Views/SendFlow/AddressList/index.js b/app/components/Views/SendFlow/AddressList/index.js index 21d5441dd31..d15a19a734b 100644 --- a/app/components/Views/SendFlow/AddressList/index.js +++ b/app/components/Views/SendFlow/AddressList/index.js @@ -12,6 +12,8 @@ import { TRANSFER_FUNCTION_SIGNATURE, TRANSFER_FROM_FUNCTION_SIGNATURE } from '../../../../util/transactions'; +import { swapsUtils } from '@metamask/swaps-controller'; +import { toLowerCaseEquals } from '../../../../util/general'; const styles = StyleSheet.create({ root: { @@ -97,7 +99,11 @@ class AddressList extends PureComponent { * Whether it only has to render address book */ onlyRenderAddressBook: PropTypes.bool, - reloadAddressList: PropTypes.bool + reloadAddressList: PropTypes.bool, + /** + * Chain id + */ + chainId: PropTypes.string }; state = { @@ -153,7 +159,7 @@ class AddressList extends PureComponent { }; getRecentAddresses = inputSearch => { - const { transactions, network, identities, onAccountPress, onAccountLongPress } = this.props; + const { transactions, network, identities, onAccountPress, onAccountLongPress, chainId } = this.props; const recents = []; const parsedRecents = []; if (!inputSearch) { @@ -171,7 +177,12 @@ class AddressList extends PureComponent { } const checksummedTo = safeToChecksumAddress(to); if (recents.length > 2) return; - if (!recents.includes(checksummedTo) && !Object.keys(identities).includes(checksummedTo)) { + const swapsContractAddress = swapsUtils.getSwapsContractAddress(chainId); + if ( + !recents.includes(checksummedTo) && + !Object.keys(identities).includes(checksummedTo) && + !toLowerCaseEquals(checksummedTo, swapsContractAddress) + ) { recents.push(checksummedTo); if (this.networkAddressBook[checksummedTo]) { parsedRecents.push( @@ -297,7 +308,8 @@ const mapStateToProps = state => ({ addressBook: state.engine.backgroundState.AddressBookController.addressBook, identities: state.engine.backgroundState.PreferencesController.identities, network: state.engine.backgroundState.NetworkController.network, - transactions: state.engine.backgroundState.TransactionController.transactions + transactions: state.engine.backgroundState.TransactionController.transactions, + chainId: state.engine.backgroundState.NetworkController.provider.chainId }); export default connect(mapStateToProps)(AddressList); diff --git a/app/components/Views/SendFlow/AddressList/index.test.js b/app/components/Views/SendFlow/AddressList/index.test.js index a84ab9761f3..ae59ff4abef 100644 --- a/app/components/Views/SendFlow/AddressList/index.test.js +++ b/app/components/Views/SendFlow/AddressList/index.test.js @@ -10,7 +10,10 @@ describe('AddressList', () => { engine: { backgroundState: { NetworkController: { - network: '1' + network: '1', + provider: { + chainId: '1' + } }, AddressBookController: { addressBook: { diff --git a/app/components/Views/SendFlow/Amount/index.js b/app/components/Views/SendFlow/Amount/index.js index 53c1eec8db0..92fc0f5e4f7 100644 --- a/app/components/Views/SendFlow/Amount/index.js +++ b/app/components/Views/SendFlow/Amount/index.js @@ -54,7 +54,7 @@ import { ANALYTICS_EVENT_OPTS } from '../../../../util/analytics'; import dismissKeyboard from 'react-native/Libraries/Utilities/dismissKeyboard'; import NetworkMainAssetLogo from '../../../UI/NetworkMainAssetLogo'; import { isMainNet } from '../../../../util/networks'; -import { toLowerCaseCompare } from '../../../../util/general'; +import { toLowerCaseEquals } from '../../../../util/general'; const { hexToBN, BNToHex } = util; @@ -425,7 +425,7 @@ class Amount extends PureComponent { } = this.props; try { const owner = await AssetsContractController.getOwnerOf(address, tokenId); - const isOwner = toLowerCaseCompare(owner, selectedAddress); + const isOwner = toLowerCaseEquals(owner, selectedAddress); if (!isOwner) { return strings('transaction.invalid_collectible_ownership'); } diff --git a/app/components/Views/TransactionsView/index.js b/app/components/Views/TransactionsView/index.js index 130bdef8929..22692b517ee 100644 --- a/app/components/Views/TransactionsView/index.js +++ b/app/components/Views/TransactionsView/index.js @@ -8,7 +8,7 @@ import { showAlert } from '../../../actions/alert'; import Transactions from '../../UI/Transactions'; import { safeToChecksumAddress } from '../../../util/address'; import { addAccountTimeFlagFilter } from '../../../util/transactions'; -import { toLowerCaseCompare } from '../../../util/general'; +import { toLowerCaseEquals } from '../../../util/general'; const styles = StyleSheet.create({ wrapper: { @@ -52,7 +52,7 @@ const TransactionsView = ({ ) { if (isTransfer) return tokens.find(({ address }) => - toLowerCaseCompare(address, transferInformation.contractAddress) + toLowerCaseEquals(address, transferInformation.contractAddress) ); return true; } diff --git a/app/reducers/swaps/index.js b/app/reducers/swaps/index.js index 9bf49c0c0fd..a0d3f16b8ff 100644 --- a/app/reducers/swaps/index.js +++ b/app/reducers/swaps/index.js @@ -2,7 +2,7 @@ import { createSelector } from 'reselect'; import contractMetadata from '@metamask/contract-metadata'; import { isMainnetByChainId } from '../../util/networks'; import { safeToChecksumAddress } from '../../util/address'; -import { toLowerCaseCompare } from '../../util/general'; +import { toLowerCaseEquals } from '../../util/general'; // * Constants export const SWAPS_SET_LIVENESS = 'SWAPS_SET_LIVENESS'; @@ -167,7 +167,7 @@ export const swapsTopAssetsSelector = createSelector( return []; } const result = topAssets - .map(({ address }) => tokens?.find(token => toLowerCaseCompare(token.address, address))) + .map(({ address }) => tokens?.find(token => toLowerCaseEquals(token.address, address))) .filter(Boolean); return addMetadata(chainId, result); } diff --git a/app/store/migrations.js b/app/store/migrations.js index 0d2e734600a..9e19f4a9455 100644 --- a/app/store/migrations.js +++ b/app/store/migrations.js @@ -1,7 +1,7 @@ import { NetworksChainId } from '@metamask/controllers'; import AppConstants from '../core/AppConstants'; import { getAllNetworks, isSafeChainId } from '../util/networks'; -import { toLowerCaseCompare } from '../util/general'; +import { toLowerCaseEquals } from '../util/general'; export const migrations = { // Needed after https://github.com/MetaMask/controllers/pull/152 @@ -22,7 +22,7 @@ export const migrations = { const tokens = state.engine.backgroundState.AssetsController.tokens; const migratedTokens = []; tokens.forEach(token => { - if (token.symbol === 'DAI' && toLowerCaseCompare(token.address, AppConstants.SAI_ADDRESS)) { + if (token.symbol === 'DAI' && toLowerCaseEquals(token.address, AppConstants.SAI_ADDRESS)) { token.symbol = 'SAI'; } migratedTokens.push(token); diff --git a/app/util/ENSUtils.js b/app/util/ENSUtils.js index c20cc0e23f8..f14ce30743f 100644 --- a/app/util/ENSUtils.js +++ b/app/util/ENSUtils.js @@ -1,7 +1,7 @@ import Engine from '../core/Engine'; import networkMap from 'ethjs-ens/lib/network-map.json'; import ENS from 'ethjs-ens'; -import { toLowerCaseCompare } from '../util/general'; +import { toLowerCaseEquals } from '../util/general'; /** * Utility class with the single responsibility @@ -26,7 +26,7 @@ export async function doENSReverseLookup(address, network) { try { const name = await this.ens.reverse(address); const resolvedAddress = await this.ens.lookup(name); - if (toLowerCaseCompare(address, resolvedAddress)) { + if (toLowerCaseEquals(address, resolvedAddress)) { ENSCache.cache[address] = name; return name; } diff --git a/app/util/general.js b/app/util/general.js index a9512be0d6c..6cc9e75f505 100644 --- a/app/util/general.js +++ b/app/util/general.js @@ -35,7 +35,7 @@ export function findRouteNameFromNavigatorState({ routes }) { } export const capitalize = str => (str && str.charAt(0).toUpperCase() + str.slice(1)) || false; -export const toLowerCaseCompare = (a, b) => { +export const toLowerCaseEquals = (a, b) => { if (!a && !b) return false; return tlc(a) === tlc(b); }; diff --git a/app/util/general.test.js b/app/util/general.test.js index a0130171c67..a13065dbe82 100644 --- a/app/util/general.test.js +++ b/app/util/general.test.js @@ -1,4 +1,4 @@ -import { capitalize, tlc, toLowerCaseCompare } from './general'; +import { capitalize, tlc, toLowerCaseEquals } from './general'; describe('capitalize', () => { const my_string = 'string'; @@ -19,21 +19,21 @@ describe('tlc', () => { }); }); -describe('toLowerCaseCompare', () => { +describe('toLowerCaseEquals', () => { const o = {}; it('compares two things', () => { - expect(toLowerCaseCompare('A', 'A')).toEqual(true); - expect(toLowerCaseCompare('aBCDefH', 'abcdefh')).toEqual(true); - expect(toLowerCaseCompare('A', 'B')).toEqual(false); - expect(toLowerCaseCompare('aBCDefH', 'abcdefi')).toEqual(false); + expect(toLowerCaseEquals('A', 'A')).toEqual(true); + expect(toLowerCaseEquals('aBCDefH', 'abcdefh')).toEqual(true); + expect(toLowerCaseEquals('A', 'B')).toEqual(false); + expect(toLowerCaseEquals('aBCDefH', 'abcdefi')).toEqual(false); // cases where a or b are undefined - expect(toLowerCaseCompare(o.p, 'A')).toEqual(false); - expect(toLowerCaseCompare('A', o.p)).toEqual(false); - expect(toLowerCaseCompare(undefined, 'A')).toEqual(false); - expect(toLowerCaseCompare('A', undefined)).toEqual(false); + expect(toLowerCaseEquals(o.p, 'A')).toEqual(false); + expect(toLowerCaseEquals('A', o.p)).toEqual(false); + expect(toLowerCaseEquals(undefined, 'A')).toEqual(false); + expect(toLowerCaseEquals('A', undefined)).toEqual(false); // case where a and b are both undefined, null or false - expect(toLowerCaseCompare(undefined, undefined)).toEqual(false); - expect(toLowerCaseCompare(null, null)).toEqual(false); - expect(toLowerCaseCompare(false, false)).toEqual(false); + expect(toLowerCaseEquals(undefined, undefined)).toEqual(false); + expect(toLowerCaseEquals(null, null)).toEqual(false); + expect(toLowerCaseEquals(false, false)).toEqual(false); }); });