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,23 +1,35 @@
import { assert } from 'chai'
import { RippledError } from 'xrpl-local'
import { setupClient, teardownClient } from './setupClient'
import { RippledError } from '../src'
import {
setupClient,
teardownClient,
type XrplTestContext,
} from './setupClient'
import { assertRejects } from './testUtils'
describe('mock rippled tests', function () {
beforeEach(setupClient)
afterEach(teardownClient)
let testContext: XrplTestContext
beforeEach(async () => {
testContext = await setupClient()
})
afterEach(async () => teardownClient(testContext))
it('errors if a mock is not provided', async function () {
this.mockRippled.suppressOutput = true
if (testContext.mockRippled) {
testContext.mockRippled.suppressOutput = true
}
await assertRejects(
this.client.request({ command: 'server_info' }),
testContext.client.request({ command: 'server_info' }),
RippledError,
)
})
it('provide bad response shape', async function () {
try {
this.mockRippled.addResponse('account_info', { data: {} })
testContext.mockRippled!.addResponse('account_info', { data: {} })
assert.fail('Should have errored')
} catch (err) {
if (!(err instanceof Error)) {
@@ -27,12 +39,12 @@ describe('mock rippled tests', function () {
})
it('provide bad response shape in function', async function () {
this.mockRippled.suppressOutput = true
this.mockRippled.addResponse('account_info', (request) => {
testContext.mockRippled!.suppressOutput = true
testContext.mockRippled!.addResponse('account_info', (request) => {
return { data: request }
})
await assertRejects(
this.client.request({ command: 'account_info', account: '' }),
testContext.client.request({ command: 'account_info', account: '' }),
RippledError,
)
})