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 sendBCHMock from '../__mocks__/sendBCH'; | import sendBCHMock from '../__mocks__/sendBCH'; | ||||
import createTokenMock from '../__mocks__/createToken'; | import createTokenMock from '../__mocks__/createToken'; | ||||
import { validStoredWallet } from '../../utils/__mocks__/mockStoredWallets'; | import { burnTokenWallet } from '../__mocks__/burnToken'; | ||||
import { currency } from '../../components/Common/Ticker'; | import { currency } from '../../components/Common/Ticker'; | ||||
import BigNumber from 'bignumber.js'; | import BigNumber from 'bignumber.js'; | ||||
import { fromSatoshisToXec } from 'utils/cashMethods'; | import { fromSatoshisToXec } from 'utils/cashMethods'; | ||||
import { ChronikClient } from 'chronik-client'; // for mocking purposes | import { ChronikClient } from 'chronik-client'; // for mocking purposes | ||||
describe('useBCH hook', () => { | describe('useBCH hook', () => { | ||||
it('gets primary Rest API URL on mainnet', () => { | it('gets primary Rest API URL on mainnet', () => { | ||||
process = { | process = { | ||||
▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | it('Throws error on attempt to send one satoshi less than backend dust limit', async () => { | ||||
.minus(new BigNumber('0.00000001')) | .minus(new BigNumber('0.00000001')) | ||||
.toString(), | .toString(), | ||||
); | ); | ||||
expect(failedSendBch).rejects.toThrow(new Error('dust')); | expect(failedSendBch).rejects.toThrow(new Error('dust')); | ||||
}); | }); | ||||
it("Throws error attempting to burn an eToken ID that is not within the wallet's utxo", async () => { | it("Throws error attempting to burn an eToken ID that is not within the wallet's utxo", async () => { | ||||
const { burnToken } = useBCH(); | const { burnToken } = useBCH(); | ||||
const wallet = validStoredWallet; | const wallet = burnTokenWallet; | ||||
const burnAmount = 10; | const burnAmount = 10; | ||||
const eTokenId = '0203c768a66eba24affNOTVALID103b772de4d9f8f63ba79e'; | const eTokenId = '0203c768a66eba24affNOTVALID103b772de4d9f8f63ba79e'; | ||||
const expectedError = | const expectedError = | ||||
'No token UTXOs for the specified token could be found.'; | 'No token UTXOs for the specified token could be found.'; | ||||
const chronik = new ChronikClient( | const chronik = new ChronikClient( | ||||
'https://FakeChronikUrlToEnsureMocksOnly.com', | 'https://FakeChronikUrlToEnsureMocksOnly.com', | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 146 Lines • Show Last 20 Lines |