mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-29 00:25:48 +00:00
xahau-patch
This commit is contained in:
60
packages/xahau/test/mockRippledTest.test.ts
Normal file
60
packages/xahau/test/mockRippledTest.test.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { XahaudError } from '../src'
|
||||
|
||||
import xahaudFixtures from './fixtures/xahaud'
|
||||
import {
|
||||
setupClient,
|
||||
teardownClient,
|
||||
type XrplTestContext,
|
||||
} from './setupClient'
|
||||
import { assertRejects } from './testUtils'
|
||||
|
||||
describe('mock xahaud tests', function () {
|
||||
let testContext: XrplTestContext
|
||||
|
||||
beforeEach(async () => {
|
||||
testContext = await setupClient()
|
||||
})
|
||||
afterEach(async () => teardownClient(testContext))
|
||||
it('errors if a mock is not provided', async function () {
|
||||
if (testContext.mockRippled) {
|
||||
testContext.mockRippled.suppressOutput = true
|
||||
}
|
||||
|
||||
await assertRejects(
|
||||
testContext.client.request({
|
||||
command: 'account_info',
|
||||
account:
|
||||
xahaudFixtures.account_info.normal.result.account_data.Account,
|
||||
}),
|
||||
XahaudError,
|
||||
)
|
||||
})
|
||||
|
||||
it('provide bad response shape', async function () {
|
||||
try {
|
||||
testContext.mockRippled!.addResponse('account_info', { data: {} })
|
||||
assert.fail('Should have errored')
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
assert.fail(`Wrong error type: ${err as string}`)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
it('provide bad response shape in function', async function () {
|
||||
testContext.mockRippled!.suppressOutput = true
|
||||
testContext.mockRippled!.addResponse('account_info', (request) => {
|
||||
return { data: request }
|
||||
})
|
||||
await assertRejects(
|
||||
testContext.client.request({
|
||||
command: 'account_info',
|
||||
account:
|
||||
xahaudFixtures.account_info.normal.result.account_data.Account,
|
||||
}),
|
||||
XahaudError,
|
||||
)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user