Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/__tests__/useBCH.test.js
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | it('sends BCH correctly', async () => { | ||||
1.01, | 1.01, | ||||
), | ), | ||||
).toBe(`${currency.blockExplorerUrl}/tx/${expectedTxId}`); | ).toBe(`${currency.blockExplorerUrl}/tx/${expectedTxId}`); | ||||
expect(BCH.RawTransactions.sendRawTransaction).toHaveBeenCalledWith( | expect(BCH.RawTransactions.sendRawTransaction).toHaveBeenCalledWith( | ||||
expectedHex, | expectedHex, | ||||
); | ); | ||||
}); | }); | ||||
it('sends BCH correctly with callback', async () => { | |||||
const { sendBch } = useBCH(); | |||||
const BCH = new BCHJS(); | |||||
const callback = jest.fn(); | |||||
const { | |||||
expectedTxId, | |||||
expectedHex, | |||||
utxos, | |||||
wallet, | |||||
destinationAddress, | |||||
sendAmount, | |||||
} = sendBCHMock; | |||||
BCH.RawTransactions.sendRawTransaction = jest | |||||
.fn() | |||||
.mockResolvedValue(expectedTxId); | |||||
expect( | |||||
await sendBch( | |||||
BCH, | |||||
wallet, | |||||
utxos, | |||||
destinationAddress, | |||||
sendAmount, | |||||
1.01, | |||||
callback, | |||||
), | |||||
).toBe(`${currency.blockExplorerUrl}/tx/${expectedTxId}`); | |||||
expect(BCH.RawTransactions.sendRawTransaction).toHaveBeenCalledWith( | |||||
expectedHex, | |||||
); | |||||
expect(callback).toHaveBeenCalledWith(expectedTxId); | |||||
}); | |||||
it(`Throws error if called trying to send one base unit ${currency.ticker} more than available in utxo set`, async () => { | it(`Throws error if called trying to send one base unit ${currency.ticker} more than available in utxo set`, async () => { | ||||
const { sendBch } = useBCH(); | const { sendBch } = useBCH(); | ||||
const BCH = new BCHJS(); | const BCH = new BCHJS(); | ||||
const { expectedTxId, utxos, wallet, destinationAddress } = sendBCHMock; | const { expectedTxId, utxos, wallet, destinationAddress } = sendBCHMock; | ||||
const expectedTxFeeInSats = 229; | const expectedTxFeeInSats = 229; | ||||
BCH.RawTransactions.sendRawTransaction = jest | BCH.RawTransactions.sendRawTransaction = jest | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |