mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
feat: Jest Test Runner (#2170)
This commit is contained in:
@@ -2,29 +2,40 @@ import { assert } from 'chai'
|
||||
|
||||
import getFeeXrp from '../../src/sugar/getFeeXrp'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import { setupClient, teardownClient } from '../setupClient'
|
||||
import {
|
||||
setupClient,
|
||||
teardownClient,
|
||||
type XrplTestContext,
|
||||
} from '../setupClient'
|
||||
|
||||
describe('getFeeXrp', function () {
|
||||
beforeEach(setupClient)
|
||||
afterEach(teardownClient)
|
||||
let testContext: XrplTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient()
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
|
||||
it('getFeeXrp', async function () {
|
||||
this.mockRippled.addResponse('server_info', rippled.server_info.normal)
|
||||
const fee = await getFeeXrp(this.client)
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.normal,
|
||||
)
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '0.000012')
|
||||
})
|
||||
|
||||
it('getFeeXrp - high load_factor', async function () {
|
||||
this.mockRippled.addResponse(
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.highLoadFactor,
|
||||
)
|
||||
const fee = await getFeeXrp(this.client)
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '2')
|
||||
})
|
||||
|
||||
it('getFeeXrp - high load_factor with custom maxFeeXRP', async function () {
|
||||
this.mockRippled.addResponse(
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.highLoadFactor,
|
||||
)
|
||||
@@ -33,15 +44,20 @@ describe('getFeeXrp', function () {
|
||||
* Ensure that overriding with high maxFeeXRP of '51540' causes no errors.
|
||||
* (fee will actually be 51539.607552)
|
||||
*/
|
||||
this.client.maxFeeXRP = '51540'
|
||||
const fee = await getFeeXrp(this.client)
|
||||
// @ts-expect-error Manually setting this for the purpose of testing
|
||||
testContext.client.maxFeeXRP = '51540'
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '51539.607552')
|
||||
})
|
||||
|
||||
it('getFeeXrp custom cushion', async function () {
|
||||
this.mockRippled.addResponse('server_info', rippled.server_info.normal)
|
||||
this.client.feeCushion = 1.4
|
||||
const fee = await getFeeXrp(this.client)
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.normal,
|
||||
)
|
||||
// @ts-expect-error Manually setting this for the purpose of testing
|
||||
testContext.client.feeCushion = 1.4
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '0.000014')
|
||||
})
|
||||
|
||||
@@ -50,15 +66,22 @@ describe('getFeeXrp', function () {
|
||||
* less than the base fee. However, this test verifies the existing behavior.
|
||||
*/
|
||||
it('getFeeXrp cushion less than 1.0', async function () {
|
||||
this.mockRippled.addResponse('server_info', rippled.server_info.normal)
|
||||
this.client.feeCushion = 0.9
|
||||
const fee = await getFeeXrp(this.client)
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.normal,
|
||||
)
|
||||
// @ts-expect-error Manually setting this for the purpose of testing
|
||||
testContext.client.feeCushion = 0.9
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '0.000009')
|
||||
})
|
||||
|
||||
it('getFeeXrp reporting', async function () {
|
||||
this.mockRippled.addResponse('server_info', rippled.server_info.normal)
|
||||
const fee = await getFeeXrp(this.client)
|
||||
testContext.mockRippled!.addResponse(
|
||||
'server_info',
|
||||
rippled.server_info.normal,
|
||||
)
|
||||
const fee = await getFeeXrp(testContext.client)
|
||||
assert.strictEqual(fee, '0.000012')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user