mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
test: removes the use of TestSuite (#1566)* switch all methods to new format* clean up rippleClient* rename files to remove ripple from name* additional cleanup
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { assert } from "chai";
|
||||
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, TestSuite } from "../testUtils";
|
||||
import setupClient from "../setupClient";
|
||||
import { assertRejects } from "../testUtils";
|
||||
|
||||
const rippledResponse = function (request: Request): object {
|
||||
if ("marker" in request) {
|
||||
@@ -10,16 +11,13 @@ const rippledResponse = function (request: Request): object {
|
||||
return rippled.ledger_data.first_page;
|
||||
};
|
||||
|
||||
/**
|
||||
* Every test suite exports their tests in the default object.
|
||||
* - Check out the "TestSuite" type for documentation on the interface.
|
||||
* - Check out "test/client/index.ts" for more information about the test runner.
|
||||
*/
|
||||
export default <TestSuite>{
|
||||
"requests the next page": async (client, address, mockRippled) => {
|
||||
mockRippled.addResponse("ledger_data", rippledResponse);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await client.requestNextPage(
|
||||
describe("client.requestNextPage", function () {
|
||||
beforeEach(setupClient.setup);
|
||||
afterEach(setupClient.teardown);
|
||||
it("requests the next page", async function () {
|
||||
this.mockRippled.addResponse("ledger_data", rippledResponse);
|
||||
const response = await this.client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await this.client.requestNextPage(
|
||||
{ command: "ledger_data" },
|
||||
response
|
||||
);
|
||||
@@ -27,24 +25,20 @@ export default <TestSuite>{
|
||||
responseNextPage.result.state[0].index,
|
||||
"000B714B790C3C79FEE00D17C4DEB436B375466F29679447BA64F265FD63D731"
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
"rejects when there are no more pages": async (
|
||||
client,
|
||||
address,
|
||||
mockRippled
|
||||
) => {
|
||||
mockRippled.addResponse("ledger_data", rippledResponse);
|
||||
const response = await client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await client.requestNextPage(
|
||||
it("rejects when there are no more pages", async function () {
|
||||
this.mockRippled.addResponse("ledger_data", rippledResponse);
|
||||
const response = await this.client.request({ command: "ledger_data" });
|
||||
const responseNextPage = await this.client.requestNextPage(
|
||||
{ command: "ledger_data" },
|
||||
response
|
||||
);
|
||||
assert(!client.hasNextPage(responseNextPage));
|
||||
assert(!this.client.hasNextPage(responseNextPage));
|
||||
await assertRejects(
|
||||
client.requestNextPage({ command: "ledger_data" }, responseNextPage),
|
||||
this.client.requestNextPage({ command: "ledger_data" }, responseNextPage),
|
||||
Error,
|
||||
"response does not have a next page"
|
||||
);
|
||||
},
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user