mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 15:45:48 +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,7 +1,7 @@
|
||||
import responses from '../fixtures/responses'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import rippledAccountLines from '../fixtures/rippled/accountLines'
|
||||
import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
import responses from "../fixtures/responses";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import rippledAccountLines from "../fixtures/rippled/accountLines";
|
||||
import { assertResultMatch, TestSuite } from "../testUtils";
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
@@ -9,54 +9,82 @@ import {assertResultMatch, TestSuite} from '../testUtils'
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
'getBalances': async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
const result = await client.getBalances(address)
|
||||
assertResultMatch(result, responses.getBalances, 'getBalances')
|
||||
async getBalances(client, address, mockRippled) {
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const result = await client.getBalances(address);
|
||||
assertResultMatch(result, responses.getBalances, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit': async (client, address, mockRippled) => {
|
||||
const options = {limit: 3, ledgerVersion: 123456}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
const expectedResponse = responses.getBalances.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
"getBalances - limit": async (client, address, mockRippled) => {
|
||||
const options = { limit: 3, ledgerVersion: 123456 };
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const expectedResponse = responses.getBalances.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit & currency': async (client, address, mockRippled) => {
|
||||
const options = {currency: 'USD', limit: 3}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
"getBalances - limit & currency": async (client, address, mockRippled) => {
|
||||
const options = { currency: "USD", limit: 3 };
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
const expectedResponse = responses.getBalances
|
||||
.filter((item) => item.currency === 'USD')
|
||||
.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
.filter((item) => item.currency === "USD")
|
||||
.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
|
||||
'getBalances - limit & currency & issuer': async (client, address, mockRippled) => {
|
||||
"getBalances - limit & currency & issuer": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
const options = {
|
||||
currency: 'USD',
|
||||
counterparty: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
|
||||
limit: 3
|
||||
}
|
||||
mockRippled.addResponse({command: 'account_info'}, rippled.account_info.normal)
|
||||
mockRippled.addResponse({command: 'account_lines'}, rippledAccountLines.normal)
|
||||
mockRippled.addResponse({command: 'ledger'}, rippled.ledger.normal)
|
||||
|
||||
currency: "USD",
|
||||
counterparty: "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B",
|
||||
limit: 3,
|
||||
};
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_info" },
|
||||
rippled.account_info.normal
|
||||
);
|
||||
mockRippled.addResponse(
|
||||
{ command: "account_lines" },
|
||||
rippledAccountLines.normal
|
||||
);
|
||||
mockRippled.addResponse({ command: "ledger" }, rippled.ledger.normal);
|
||||
|
||||
const expectedResponse = responses.getBalances
|
||||
.filter(
|
||||
(item) =>
|
||||
item.currency === 'USD' &&
|
||||
item.counterparty === 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
|
||||
item.currency === "USD" &&
|
||||
item.counterparty === "rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B"
|
||||
)
|
||||
.slice(0, 3)
|
||||
const result = await client.getBalances(address, options)
|
||||
assertResultMatch(result, expectedResponse, 'getBalances')
|
||||
}
|
||||
}
|
||||
.slice(0, 3);
|
||||
const result = await client.getBalances(address, options);
|
||||
assertResultMatch(result, expectedResponse, "getBalances");
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user