Skip to content

Commit

Permalink
fix: standardizeWitUnits function
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon authored and mariocao committed Apr 6, 2020
1 parent 50a58cf commit 3aef264
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export function standardizeWitUnits(amount, unit) {
[`${WIT_UNIT.MICRO}`]: 3,
[`${WIT_UNIT.NANO}`]: 0,
}
return (amount / Math.pow(10, units[unit])).toFixed(units[unit]).replace(/\.?0+$/, '')
if (unit === WIT_UNIT.NANO) {
return amount.toString()
} else {
return (amount / Math.pow(10, units[unit])).toFixed(units[unit]).replace(/\.?0+$/, '')
}
}

export function encodeDataRequest(radRequest) {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/src/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ describe('standardizeWitUnits', () => {
})
})
it('nanoWit', () => {
const expected = '4'
const result = standardizeWitUnits(4, WIT_UNIT.NANO)
const expected = '40'
const result = standardizeWitUnits(40, WIT_UNIT.NANO)
expect(result).toBe(expected)
})
})
Expand Down

0 comments on commit 3aef264

Please sign in to comment.