Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/__tests__/migrations.test.js
Show All 29 Lines | describe('Testing functions for upgrading Cashtab', () => { | ||||
it(`toSmallestDenomination() returns expected value if input is a BigNumber with 2 decimal places`, () => { | it(`toSmallestDenomination() returns expected value if input is a BigNumber with 2 decimal places`, () => { | ||||
const { toSmallestDenomination } = useBCH(); | const { toSmallestDenomination } = useBCH(); | ||||
const testInput = new BigNumber('100.12'); | const testInput = new BigNumber('100.12'); | ||||
expect(toSmallestDenomination(testInput, 2)).toStrictEqual( | expect(toSmallestDenomination(testInput, 2)).toStrictEqual( | ||||
new BigNumber('10012'), | new BigNumber('10012'), | ||||
); | ); | ||||
}); | }); | ||||
it(`toSmallestDenomination() returns expected value if input is a BigNumber with 1 decimal place`, () => { | |||||
const { toSmallestDenomination } = useBCH(); | |||||
const testInput = new BigNumber('100.1'); | |||||
expect(toSmallestDenomination(testInput, 8)).toStrictEqual( | |||||
new BigNumber('10010000000'), | |||||
); | |||||
}); | |||||
it('toSmallestDenomination() returns exact result as toSatoshi but in BigNumber format', () => { | it('toSmallestDenomination() returns exact result as toSatoshi but in BigNumber format', () => { | ||||
const BCH = new BCHJS(); | const BCH = new BCHJS(); | ||||
const { toSmallestDenomination } = useBCH(); | const { toSmallestDenomination } = useBCH(); | ||||
const testAmount = new BigNumber('0.12345678'); | const testAmount = new BigNumber('0.12345678'); | ||||
// Match legacy implementation, inputting a BigNumber converted to a string by .toFixed(8) | // Match legacy implementation, inputting a BigNumber converted to a string by .toFixed(8) | ||||
const testAmountInSatoshis = BCH.BitcoinCash.toSatoshi( | const testAmountInSatoshis = BCH.BitcoinCash.toSatoshi( | ||||
Show All 11 Lines |