mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
build: Initial linting setup (#1560)
* sets up linting config and runs `yarn lint --fix` once, so that all changes will show up correctly in future PRs. * Note that there are still a lot of linter errors.
This commit is contained in:
committed by
Mayukha Vadari
parent
12cfed5c17
commit
8b95ee5fab
@@ -1,53 +1,52 @@
|
||||
import _ from 'lodash'
|
||||
import assert from 'assert-diff'
|
||||
import setupClient from './setupClient'
|
||||
import responses from './fixtures/responses'
|
||||
import rippled from './fixtures/rippled'
|
||||
import {ignoreWebSocketDisconnect} from './testUtils'
|
||||
import assert from "assert-diff";
|
||||
import _ from "lodash";
|
||||
|
||||
const TIMEOUT = 20000
|
||||
import responses from "./fixtures/responses";
|
||||
import rippled from "./fixtures/rippled";
|
||||
import setupClient from "./setupClient";
|
||||
import { ignoreWebSocketDisconnect } from "./testUtils";
|
||||
|
||||
const TIMEOUT = 20000;
|
||||
|
||||
function checkResult(expected, response) {
|
||||
if (expected.txJSON) {
|
||||
assert(response.txJSON)
|
||||
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON))
|
||||
assert(response.txJSON);
|
||||
assert.deepEqual(JSON.parse(response.txJSON), JSON.parse(expected.txJSON));
|
||||
}
|
||||
assert.deepEqual(_.omit(response, 'txJSON'), _.omit(expected, 'txJSON'))
|
||||
return response
|
||||
assert.deepEqual(_.omit(response, "txJSON"), _.omit(expected, "txJSON"));
|
||||
return response;
|
||||
}
|
||||
|
||||
describe('BroadcastClient', function () {
|
||||
this.timeout(TIMEOUT)
|
||||
beforeEach(setupClient.setupBroadcast)
|
||||
afterEach(setupClient.teardown)
|
||||
describe("BroadcastClient", function () {
|
||||
this.timeout(TIMEOUT);
|
||||
beforeEach(setupClient.setupBroadcast);
|
||||
afterEach(setupClient.teardown);
|
||||
|
||||
it('base', function () {
|
||||
it("base", function () {
|
||||
this.mocks.forEach((mock) => {
|
||||
mock.addResponse({command: 'server_info'}, rippled.server_info.normal)
|
||||
})
|
||||
assert(this.client.isConnected())
|
||||
return this.client
|
||||
.request({command: "server_info"})
|
||||
.then(response => {
|
||||
return checkResult(responses.getServerInfo, response.result.info)
|
||||
})
|
||||
})
|
||||
mock.addResponse({ command: "server_info" }, rippled.server_info.normal);
|
||||
});
|
||||
assert(this.client.isConnected());
|
||||
return this.client.request({ command: "server_info" }).then((response) => {
|
||||
return checkResult(responses.getServerInfo, response.result.info);
|
||||
});
|
||||
});
|
||||
|
||||
it('error propagation', function (done) {
|
||||
const data = {error: 'type', error_message: 'info'}
|
||||
it("error propagation", function (done) {
|
||||
const data = { error: "type", error_message: "info" };
|
||||
this.mocks.forEach((mock) => {
|
||||
mock.addResponse({command: 'echo'}, data)
|
||||
})
|
||||
this.client.once('error', (type, info) => {
|
||||
assert.strictEqual(type, 'type')
|
||||
assert.strictEqual(info, 'info')
|
||||
done()
|
||||
})
|
||||
mock.addResponse({ command: "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
|
||||
command: "echo",
|
||||
data,
|
||||
})
|
||||
.catch(ignoreWebSocketDisconnect)
|
||||
})
|
||||
})
|
||||
.catch(ignoreWebSocketDisconnect);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user