Files
xahau.js/packages/xrpl/test/integration/onConnect.test.ts
justinr1234 3b70a3b919 fix: make docs not output confusing information in xrpl client (#2337)
* fix: make docs not output confusing information in xrpl client

---------

Co-authored-by: Jackson Mills <jmills@ripple.com>
Co-authored-by: Caleb Kniffen <ckniffen@ripple.com>
2024-02-01 13:43:55 -06:00

43 lines
996 B
TypeScript

import { assert } from 'chai'
import { Client } from '../../src'
import serverUrl from './serverUrl'
// how long before each test case times out
const TIMEOUT = 20000
describe('on handlers', function () {
it(
'on connect',
async () => {
const client = new Client(serverUrl)
return new Promise<void>(function (resolve) {
client.on('connected', function () {
client.removeAllListeners()
client.disconnect().then(() => resolve())
})
client.connect()
})
},
TIMEOUT,
)
it(
'on disconnect',
async () => {
const client = new Client(serverUrl)
return new Promise<void>(function (resolve) {
client.on('disconnected', function (code) {
// should be the normal disconnect code
assert.equal(code, 1000)
client.removeAllListeners()
resolve()
})
client.connect().then(async () => client.disconnect())
})
},
TIMEOUT,
)
})