feat: Jest Test Runner (#2170)

This commit is contained in:
justinr1234
2023-02-03 17:03:07 -06:00
committed by GitHub
parent 5a63f18faf
commit 5fe480ece4
229 changed files with 13497 additions and 17033 deletions

View File

@@ -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')
})
})