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:
Mayukha Vadari
2021-08-30 18:04:06 -04:00
parent 43802f9e22
commit 6268b9ea26
41 changed files with 3880 additions and 3699 deletions

View File

@@ -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"
);
},
};
});
});