mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
* lint broadcastClient * lint client * fix most of connection * remove unused files * lint mockRippled * lint mockRippledTest * lint runClientTests * lint setupClient * lint setupClientWeb * lint shamap * lint testUtils * resolve tsc issues * Fix tests * lint rest of connection * respond to comments
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { assert } from 'chai'
|
|
import _ from 'lodash'
|
|
|
|
import { ServerInfoResponse } from '../src'
|
|
|
|
import responses from './fixtures/responses'
|
|
import rippled from './fixtures/rippled'
|
|
import { setupBroadcast, teardownClient } from './setupClient'
|
|
import { assertResultMatch, ignoreWebSocketDisconnect } from './testUtils'
|
|
|
|
const TIMEOUT = 20000
|
|
|
|
describe('BroadcastClient', function () {
|
|
this.timeout(TIMEOUT)
|
|
beforeEach(setupBroadcast)
|
|
afterEach(teardownClient)
|
|
|
|
it('base', async function () {
|
|
this.mocks.forEach((mock) => {
|
|
mock.addResponse('server_info', rippled.server_info.normal)
|
|
})
|
|
assert(this.client.isConnected())
|
|
this.client
|
|
.request({ command: 'server_info' })
|
|
.then((response: ServerInfoResponse) => {
|
|
assertResultMatch(responses.getServerInfo, response.result.info)
|
|
})
|
|
})
|
|
|
|
it('error propagation', function (done) {
|
|
const data = { error: 'type', error_message: 'info' }
|
|
this.mocks.forEach((mock) => {
|
|
mock.addResponse('echo', data)
|
|
})
|
|
this.client.once('error', (type, info) => {
|
|
assert.strictEqual(type, 'type')
|
|
assert.strictEqual(info, 'info')
|
|
done()
|
|
})
|
|
this.client.clients[1].connection
|
|
.request({
|
|
command: 'echo',
|
|
data,
|
|
})
|
|
.catch(ignoreWebSocketDisconnect)
|
|
})
|
|
})
|