mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
refactor: clean up Client and associated files (#1556)
* remove _PRIVATE * make requestAll public * un-type connection.request * fix lodash imports * add comments * Rename files to camelCase
This commit is contained in:
@@ -4,8 +4,8 @@ import assert from 'assert-diff'
|
||||
import setupClient from './setupClient'
|
||||
import {Client} from 'xrpl-local'
|
||||
import {ignoreWebSocketDisconnect} from './testUtils'
|
||||
import {Connection} from 'xrpl-local/client'
|
||||
import rippled from './fixtures/rippled'
|
||||
const utils = Client._PRIVATE.ledgerUtils
|
||||
|
||||
const TIMEOUT = 200000 // how long before each test case times out
|
||||
const isBrowser = (process as any).browser
|
||||
@@ -29,7 +29,7 @@ describe('Connection', function () {
|
||||
afterEach(setupClient.teardown)
|
||||
|
||||
it('default options', function () {
|
||||
const connection: any = new utils.Connection('url')
|
||||
const connection: any = new Connection('url')
|
||||
assert.strictEqual(connection._url, 'url')
|
||||
assert(connection._config.proxy == null)
|
||||
assert(connection._config.authorization == null)
|
||||
@@ -52,7 +52,7 @@ describe('Connection', function () {
|
||||
it('as false', function () {
|
||||
const messages = []
|
||||
console.log = (id, message) => messages.push([id, message])
|
||||
const connection: any = new utils.Connection('url', {trace: false})
|
||||
const connection: any = new Connection('url', {trace: false})
|
||||
connection._ws = {send: function () {}}
|
||||
connection.request(mockedRequestData)
|
||||
connection._onMessage(mockedResponse)
|
||||
@@ -62,7 +62,7 @@ describe('Connection', function () {
|
||||
it('as true', function () {
|
||||
const messages = []
|
||||
console.log = (id, message) => messages.push([id, message])
|
||||
const connection: any = new utils.Connection('url', {trace: true})
|
||||
const connection: any = new Connection('url', {trace: true})
|
||||
connection._ws = {send: function () {}}
|
||||
connection.request(mockedRequestData)
|
||||
connection._onMessage(mockedResponse)
|
||||
@@ -71,7 +71,7 @@ describe('Connection', function () {
|
||||
|
||||
it('as a function', function () {
|
||||
const messages = []
|
||||
const connection: any = new utils.Connection('url', {
|
||||
const connection: any = new Connection('url', {
|
||||
trace: (id, message) => messages.push([id, message])
|
||||
})
|
||||
connection._ws = {send: function () {}}
|
||||
@@ -104,7 +104,7 @@ describe('Connection', function () {
|
||||
authorization: 'authorization',
|
||||
trustedCertificates: ['path/to/pem']
|
||||
}
|
||||
const connection = new utils.Connection(
|
||||
const connection = new Connection(
|
||||
this.client.connection._url,
|
||||
options
|
||||
)
|
||||
@@ -124,7 +124,7 @@ describe('Connection', function () {
|
||||
})
|
||||
|
||||
it('NotConnectedError', function () {
|
||||
const connection = new utils.Connection('url')
|
||||
const connection = new Connection('url')
|
||||
return connection.request({
|
||||
command: 'ledger',
|
||||
ledger_index: 'validated'
|
||||
@@ -148,7 +148,7 @@ describe('Connection', function () {
|
||||
}
|
||||
|
||||
// Address where no one listens
|
||||
const connection = new utils.Connection(
|
||||
const connection = new Connection(
|
||||
'ws://testripple.circleci.com:129'
|
||||
)
|
||||
connection.on('error', done)
|
||||
@@ -411,7 +411,7 @@ describe('Connection', function () {
|
||||
})
|
||||
|
||||
it('Cannot connect because no server', function () {
|
||||
const connection = new utils.Connection(undefined as string)
|
||||
const connection = new Connection(undefined as string)
|
||||
return connection
|
||||
.connect()
|
||||
.then(() => {
|
||||
|
||||
Reference in New Issue
Block a user