Skip to content

Commit

Permalink
test(Formatter): Adjust magnitude, more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak committed Feb 13, 2020
1 parent fd31fbd commit b092f94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions es/utils/amount-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export const AE_AMOUNT_FORMATS = {
*/
const DENOMINATION_MAGNITUDE = {
[AE_AMOUNT_FORMATS.AE]: 18,
[AE_AMOUNT_FORMATS.AETTOS]: 0,
[AE_AMOUNT_FORMATS.MICRO_AE]: 12,
[AE_AMOUNT_FORMATS.PICO_AE]: 4
[AE_AMOUNT_FORMATS.PICO_AE]: 12,
[AE_AMOUNT_FORMATS.MICRO_AE]: 6,
[AE_AMOUNT_FORMATS.AETTOS]: 0
}

/**
Expand Down
14 changes: 8 additions & 6 deletions test/unit/amount-formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ describe('Amount Formatter', function () {
[1e18, AE_AMOUNT_FORMATS.AETTOS, AE_AMOUNT_FORMATS.AE, asBigNumber(1)],
[10012312, AE_AMOUNT_FORMATS.AETTOS, AE_AMOUNT_FORMATS.AE, asBigNumber(10012312).div(1e18)],
[1, AE_AMOUNT_FORMATS.AE, AE_AMOUNT_FORMATS.AE, 1],
[1, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AE, asBigNumber(0.00000000000001)],
[1, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AETTOS, asBigNumber(10000)],
[1e4, AE_AMOUNT_FORMATS.AETTOS, AE_AMOUNT_FORMATS.PICO_AE, asBigNumber(1)],
[0.0001, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AE, asBigNumber(0.000000000000000001)],
[0.00000000000001, AE_AMOUNT_FORMATS.AE, AE_AMOUNT_FORMATS.PICO_AE, asBigNumber(1)],
[0.0001, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AETTOS, asBigNumber(1)]
[1, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AE, asBigNumber(0.000001)],
[1, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AETTOS, asBigNumber(1000000000000)],
[1e12, AE_AMOUNT_FORMATS.AETTOS, AE_AMOUNT_FORMATS.PICO_AE, asBigNumber(1)],
[0.0001, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AE, asBigNumber(0.0000000001)],
[0.000001, AE_AMOUNT_FORMATS.AE, AE_AMOUNT_FORMATS.PICO_AE, asBigNumber(1)],
[0.000000000001, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.AETTOS, asBigNumber(1)],
[0.000001, AE_AMOUNT_FORMATS.MICRO_AE, AE_AMOUNT_FORMATS.AETTOS, asBigNumber(1)],
[0.000001, AE_AMOUNT_FORMATS.PICO_AE, AE_AMOUNT_FORMATS.MICRO_AE, asBigNumber(1)]
].forEach(
([v, dF, dT, e]) => parseBigNumber(e).should.be.equal(formatAmount(v, { denomination: dF, targetDenomination: dT }).toString(10))
)
Expand Down

0 comments on commit b092f94

Please sign in to comment.