Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||
import { | import { | ||||
fromSatoshisToXec, | fromSatoshisToXec, | ||||
flattenContactList, | flattenContactList, | ||||
loadStoredWallet, | loadStoredWallet, | ||||
isValidStoredWallet, | isValidStoredWallet, | ||||
fromLegacyDecimals, | fromLegacyDecimals, | ||||
convertToEcashPrefix, | convertToEcashPrefix, | ||||
isLegacyMigrationRequired, | isLegacyMigrationRequired, | ||||
toLegacyCash, | toLegacyCash, | ||||
toLegacyToken, | toLegacyToken, | ||||
toLegacyCashArray, | toLegacyCashArray, | ||||
convertEtokenToEcashAddr, | convertEtokenToEcashAddr, | ||||
parseOpReturn, | parseOpReturn, | ||||
convertEcashtoEtokenAddr, | convertEcashtoEtokenAddr, | ||||
getHashArrayFromWallet, | getHashArrayFromWallet, | ||||
checkWalletForTokenInfo, | |||||
isActiveWebsocket, | isActiveWebsocket, | ||||
parseXecSendValue, | parseXecSendValue, | ||||
getChangeAddressFromInputUtxos, | getChangeAddressFromInputUtxos, | ||||
generateOpReturnScript, | generateOpReturnScript, | ||||
generateTxInput, | generateTxInput, | ||||
generateTxOutput, | generateTxOutput, | ||||
signAndBuildTx, | signAndBuildTx, | ||||
fromXecToSatoshis, | fromXecToSatoshis, | ||||
▲ Show 20 Lines • Show All 1,336 Lines • ▼ Show 20 Lines | it(`Successfully extracts a hash160 array from a migrated wallet object`, () => { | ||||
mockLegacyWallets.migratedLegacyAlphaMainnet, | mockLegacyWallets.migratedLegacyAlphaMainnet, | ||||
), | ), | ||||
).toStrictEqual([ | ).toStrictEqual([ | ||||
'960c9ed561f1699f0c49974d50b3bb7cdc118625', | '960c9ed561f1699f0c49974d50b3bb7cdc118625', | ||||
'2be0e0c999e7e77a443ea726f82c441912fca92b', | '2be0e0c999e7e77a443ea726f82c441912fca92b', | ||||
'ba8257db65f40359989c7b894c5e88ed7b6344f6', | 'ba8257db65f40359989c7b894c5e88ed7b6344f6', | ||||
]); | ]); | ||||
}); | }); | ||||
it(`Returns decimals, name, and ticker for an eToken stored in wallet object`, () => { | |||||
expect( | |||||
checkWalletForTokenInfo( | |||||
'4bd147fc5d5ff26249a9299c46b80920c0b81f59a60e05428262160ebee0b0c3', | |||||
validStoredWallet, | |||||
), | |||||
).toStrictEqual({ | |||||
decimals: 0, | |||||
name: 'Covid19 Lifetime Immunity', | |||||
ticker: 'NOCOVID', | |||||
}); | |||||
}); | |||||
it(`Returns false for an eToken not stored in a wallet object`, () => { | |||||
expect( | |||||
checkWalletForTokenInfo( | |||||
'98183238638ecb4ddc365056e22de0e8a05448c1e6084bae247fae5a74ad4f48', | |||||
validStoredWallet, | |||||
), | |||||
).toBe(false); | |||||
}); | |||||
it(`isActiveWebsocket returns true for an active chronik websocket connection`, () => { | it(`isActiveWebsocket returns true for an active chronik websocket connection`, () => { | ||||
expect(isActiveWebsocket(activeWebsocketAlpha)).toBe(true); | expect(isActiveWebsocket(activeWebsocketAlpha)).toBe(true); | ||||
}); | }); | ||||
it(`isActiveWebsocket returns false for a disconnected chronik websocket connection`, () => { | it(`isActiveWebsocket returns false for a disconnected chronik websocket connection`, () => { | ||||
expect(isActiveWebsocket(disconnectedWebsocketAlpha)).toBe(false); | expect(isActiveWebsocket(disconnectedWebsocketAlpha)).toBe(false); | ||||
}); | }); | ||||
it(`isActiveWebsocket returns false for a null chronik websocket connection`, () => { | it(`isActiveWebsocket returns false for a null chronik websocket connection`, () => { | ||||
expect(isActiveWebsocket(null)).toBe(false); | expect(isActiveWebsocket(null)).toBe(false); | ||||
}); | }); | ||||
it(`isActiveWebsocket returns false for an active websocket connection with no subscriptions`, () => { | it(`isActiveWebsocket returns false for an active websocket connection with no subscriptions`, () => { | ||||
expect(isActiveWebsocket(unsubscribedWebsocket)).toBe(false); | expect(isActiveWebsocket(unsubscribedWebsocket)).toBe(false); | ||||
}); | }); | ||||
}); | }); |