chore: rename test files (#2181)

This commit is contained in:
justinr1234
2023-01-06 14:04:36 -06:00
committed by GitHub
parent 9e74f94c44
commit 8abcfe4640
122 changed files with 49 additions and 50 deletions

View File

@@ -0,0 +1,80 @@
import { assert } from 'chai'
import { ValidationError } from 'xrpl-local'
import {
percentToTransferRate,
decimalToTransferRate,
transferRateToDecimal,
} from '../../src'
describe('TransferRate utils', function () {
it('converts 1 percent to valid TransferRate', function () {
const billionths = percentToTransferRate('1%')
assert.equal(billionths, 1010000000)
})
it('converts .01 percent to valid TransferRate', function () {
assert.equal(decimalToTransferRate('.01'), 1010000000)
assert.equal(transferRateToDecimal(1010000000), '0.01')
})
it('Throws when TransferRate < 0%', function () {
assert.throws(
() => percentToTransferRate('-1%'),
ValidationError,
'Decimal value must be between 0 and 1.00.',
)
})
it('Throws when TransferRate < 0', function () {
assert.throws(
() => decimalToTransferRate('-.01'),
ValidationError,
'Decimal value must be between 0 and 1.00.',
)
})
it('Throws when TransferRate >100%', function () {
assert.throws(
() => percentToTransferRate('101%'),
ValidationError,
'Decimal value must be between 0 and 1.00.',
)
})
it('Throws when TransferRate >1.00', function () {
assert.throws(
() => decimalToTransferRate('1.01'),
ValidationError,
'Decimal value must be between 0 and 1.00.',
)
})
it('percentToTransferRate greater than maximum precision', function () {
assert.throws(
() => percentToTransferRate('.0000000000000011221%'),
ValidationError,
'Decimal exceeds maximum precision.',
)
})
it('decimalToTransferRate greater than maximum precision', function () {
assert.throws(
() => decimalToTransferRate('.000000000000000011221'),
ValidationError,
'Decimal exceeds maximum precision.',
)
})
it('converts 0 percent to valid 0', function () {
const billionths = percentToTransferRate('0%')
assert.equal(billionths, 0)
})
it('converts 0 to valid 0', function () {
assert.equal(decimalToTransferRate('0'), 0)
assert.equal(transferRateToDecimal(0), '0')
})
})