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

@@ -1,55 +1,67 @@
import { assert } from 'chai'
import _ from 'lodash'
import { LedgerDataRequest } from 'xrpl-local'
import { LedgerDataRequest } from '../../../src'
import type { BinaryLedgerEntry } from '../../../src/models/methods/ledgerData'
import serverUrl from '../serverUrl'
import { setupClient, teardownClient } from '../setup'
import {
setupClient,
teardownClient,
type XrplIntegrationTestContext,
} from '../setup'
// how long before each test case times out
const TIMEOUT = 20000
describe('ledger_data', function () {
this.timeout(TIMEOUT)
let testContext: XrplIntegrationTestContext
beforeEach(_.partial(setupClient, serverUrl))
afterEach(teardownClient)
it('base', async function () {
const ledgerDataRequest: LedgerDataRequest = {
command: 'ledger_data',
ledger_index: 'validated',
limit: 5,
binary: true,
}
const ledgerDataResponse = await this.client.request(ledgerDataRequest)
const expected = {
id: 0,
result: {
ledger_hash: 'string',
ledger_index: 0,
marker: 'string',
state: [
{
data: 'string',
index: 'string',
},
],
},
type: 'response',
}
assert.equal(ledgerDataResponse.type, expected.type)
assert.typeOf(ledgerDataResponse.result.ledger_hash, 'string')
assert.typeOf(ledgerDataResponse.result.ledger_index, 'number')
assert.typeOf(ledgerDataResponse.result.marker, 'string')
assert.equal(ledgerDataResponse.result.state.length, 5)
ledgerDataResponse.result.state.forEach((item) => {
assert.typeOf(item.data, 'string')
assert.typeOf(item.index, 'string')
})
beforeEach(async () => {
testContext = await setupClient(serverUrl)
})
afterEach(async () => teardownClient(testContext))
it(
'base',
async () => {
const ledgerDataRequest: LedgerDataRequest = {
command: 'ledger_data',
ledger_index: 'validated',
limit: 5,
binary: true,
}
const ledgerDataResponse = await testContext.client.request(
ledgerDataRequest,
)
const expected = {
id: 0,
result: {
ledger_hash: 'string',
ledger_index: 0,
marker: 'string',
state: [
{
data: 'string',
index: 'string',
},
],
},
type: 'response',
}
assert.equal(ledgerDataResponse.type, expected.type)
assert.typeOf(ledgerDataResponse.result.ledger_hash, 'string')
assert.typeOf(ledgerDataResponse.result.ledger_index, 'number')
assert.typeOf(ledgerDataResponse.result.marker, 'string')
assert.equal(ledgerDataResponse.result.state.length, 5)
ledgerDataResponse.result.state.forEach((item) => {
assert.typeOf((item as BinaryLedgerEntry).data, 'string')
assert.typeOf(item.index, 'string')
})
},
TIMEOUT,
)
})