Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/utils/__tests__/cashMethods.test.js
Show All 11 Lines | import { | ||||
isLegacyMigrationRequired, | isLegacyMigrationRequired, | ||||
toLegacyCash, | toLegacyCash, | ||||
toLegacyToken, | toLegacyToken, | ||||
toLegacyCashArray, | toLegacyCashArray, | ||||
parseOpReturn, | parseOpReturn, | ||||
isExcludedUtxo, | isExcludedUtxo, | ||||
whichUtxosWereAdded, | whichUtxosWereAdded, | ||||
whichUtxosWereConsumed, | whichUtxosWereConsumed, | ||||
addNewHydratedUtxos, | |||||
} from '@utils/cashMethods'; | } from '@utils/cashMethods'; | ||||
import { | import { | ||||
unbatchedArray, | unbatchedArray, | ||||
arrayBatchedByThree, | arrayBatchedByThree, | ||||
} from '../__mocks__/mockBatchedArrays'; | } from '../__mocks__/mockBatchedArrays'; | ||||
import { | import { | ||||
validAddressArrayInput, | validAddressArrayInput, | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | import { | ||||
currentUtxosAfterEtokenSendTx, | currentUtxosAfterEtokenSendTx, | ||||
utxosAddedByEtokenSendTx, | utxosAddedByEtokenSendTx, | ||||
utxosConsumedByEtokenSendTx, | utxosConsumedByEtokenSendTx, | ||||
utxosConsumedByEtokenSendTxTemplate, | utxosConsumedByEtokenSendTxTemplate, | ||||
utxosConsumedBySingleXecSendTx, | utxosConsumedBySingleXecSendTx, | ||||
utxosConsumedBySingleXecSendTxTemplate, | utxosConsumedBySingleXecSendTxTemplate, | ||||
utxosConsumedBySendAllTx, | utxosConsumedBySendAllTx, | ||||
utxosConsumedBySendAllTxTemplate, | utxosConsumedBySendAllTxTemplate, | ||||
hydratedUtxoDetailsBeforeAddingTemplate, | |||||
hydratedUtxoDetailsAfterAddingSingleUtxoTemplate, | |||||
newHydratedUtxosSingleTemplate, | |||||
addedHydratedUtxosOverTwenty, | |||||
existingHydratedUtxoDetails, | |||||
existingHydratedUtxoDetailsAfterAdd, | |||||
} from '../__mocks__/incrementalUtxoMocks'; | } from '../__mocks__/incrementalUtxoMocks'; | ||||
describe('Correctly executes cash utility functions', () => { | describe('Correctly executes cash utility functions', () => { | ||||
it(`Correctly converts smallest base unit to smallest decimal for cashDecimals = 2`, () => { | it(`Correctly converts smallest base unit to smallest decimal for cashDecimals = 2`, () => { | ||||
expect(fromSmallestDenomination(1, 2)).toBe(0.01); | expect(fromSmallestDenomination(1, 2)).toBe(0.01); | ||||
}); | }); | ||||
it(`Correctly converts largest base unit to smallest decimal for cashDecimals = 2`, () => { | it(`Correctly converts largest base unit to smallest decimal for cashDecimals = 2`, () => { | ||||
expect(fromSmallestDenomination(1000000012345678, 2)).toBe( | expect(fromSmallestDenomination(1000000012345678, 2)).toBe( | ||||
▲ Show 20 Lines • Show All 451 Lines • ▼ Show 20 Lines | describe('Correctly executes cash utility functions', () => { | ||||
test('whichUtxosWereConsumed correctly identifies consumed utxos from a send eToken tx', async () => { | test('whichUtxosWereConsumed correctly identifies consumed utxos from a send eToken tx', async () => { | ||||
expect( | expect( | ||||
whichUtxosWereConsumed( | whichUtxosWereConsumed( | ||||
previousUtxosBeforeEtokenSendTx, | previousUtxosBeforeEtokenSendTx, | ||||
currentUtxosAfterEtokenSendTx, | currentUtxosAfterEtokenSendTx, | ||||
), | ), | ||||
).toStrictEqual(utxosConsumedByEtokenSendTx); | ).toStrictEqual(utxosConsumedByEtokenSendTx); | ||||
}); | }); | ||||
test('addNewHydratedUtxos correctly adds new utxos object to existing hydratedUtxoDetails object', async () => { | |||||
expect( | |||||
addNewHydratedUtxos( | |||||
newHydratedUtxosSingleTemplate, | |||||
hydratedUtxoDetailsBeforeAddingTemplate, | |||||
), | |||||
).toStrictEqual(hydratedUtxoDetailsAfterAddingSingleUtxoTemplate); | |||||
}); | |||||
test('addNewHydratedUtxos correctly adds more than 20 new hydrated utxos to existing hydratedUtxoDetails object', async () => { | |||||
expect( | |||||
addNewHydratedUtxos( | |||||
addedHydratedUtxosOverTwenty, | |||||
existingHydratedUtxoDetails, | |||||
), | |||||
).toStrictEqual(existingHydratedUtxoDetailsAfterAdd); | |||||
}); | |||||
}); | }); |