Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/__tests__/useBCH.test.js
/* eslint-disable no-native-reassign */ | /* eslint-disable no-native-reassign */ | ||||
import useBCH from '../useBCH'; | import useBCH from '../useBCH'; | ||||
import mockReturnGetHydratedUtxoDetails from '../__mocks__/mockReturnGetHydratedUtxoDetails'; | import mockReturnGetHydratedUtxoDetails from '../__mocks__/mockReturnGetHydratedUtxoDetails'; | ||||
import mockReturnGetSlpBalancesAndUtxos from '../__mocks__/mockReturnGetSlpBalancesAndUtxos'; | import mockReturnGetSlpBalancesAndUtxos from '../__mocks__/mockReturnGetSlpBalancesAndUtxos'; | ||||
import mockReturnGetHydratedUtxoDetailsWithZeroBalance from '../__mocks__/mockReturnGetHydratedUtxoDetailsWithZeroBalance'; | |||||
import mockReturnGetSlpBalancesAndUtxosNoZeroBalance from '../__mocks__/mockReturnGetSlpBalancesAndUtxosNoZeroBalance'; | |||||
import sendBCHMock from '../__mocks__/sendBCH'; | import sendBCHMock from '../__mocks__/sendBCH'; | ||||
import mockTxHistory from '../__mocks__/mockTxHistory'; | import mockTxHistory from '../__mocks__/mockTxHistory'; | ||||
import mockFlatTxHistory from '../__mocks__/mockFlatTxHistory'; | import mockFlatTxHistory from '../__mocks__/mockFlatTxHistory'; | ||||
import mockTxDataWithPassthrough from '../__mocks__/mockTxDataWithPassthrough'; | import mockTxDataWithPassthrough from '../__mocks__/mockTxDataWithPassthrough'; | ||||
import { | import { | ||||
tokenSendWdt, | tokenSendWdt, | ||||
tokenReceiveTBS, | tokenReceiveTBS, | ||||
} from '../__mocks__/mockParseTokenInfoForTxHistory'; | } from '../__mocks__/mockParseTokenInfoForTxHistory'; | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | it('gets SLP and BCH balances and utxos from hydrated utxo details', async () => { | ||||
const result = await getSlpBalancesAndUtxos( | const result = await getSlpBalancesAndUtxos( | ||||
mockReturnGetHydratedUtxoDetails, | mockReturnGetHydratedUtxoDetails, | ||||
); | ); | ||||
expect(result).toStrictEqual(mockReturnGetSlpBalancesAndUtxos); | expect(result).toStrictEqual(mockReturnGetSlpBalancesAndUtxos); | ||||
}); | }); | ||||
it(`Ignores SLP utxos with utxo.tokenQty === '0'`, async () => { | |||||
const { getSlpBalancesAndUtxos } = useBCH(); | |||||
const result = await getSlpBalancesAndUtxos( | |||||
mockReturnGetHydratedUtxoDetailsWithZeroBalance, | |||||
); | |||||
expect(result).toStrictEqual( | |||||
mockReturnGetSlpBalancesAndUtxosNoZeroBalance, | |||||
); | |||||
}); | |||||
it('sends BCH correctly', async () => { | it('sends BCH correctly', async () => { | ||||
const { sendBch } = useBCH(); | const { sendBch } = useBCH(); | ||||
const BCH = new BCHJS(); | const BCH = new BCHJS(); | ||||
const { | const { | ||||
expectedTxId, | expectedTxId, | ||||
expectedHex, | expectedHex, | ||||
utxos, | utxos, | ||||
wallet, | wallet, | ||||
▲ Show 20 Lines • Show All 252 Lines • Show Last 20 Lines |