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,60 +1,80 @@
import requests from "../fixtures/requests";
import responses from "../fixtures/responses";
import rippled from "../fixtures/rippled";
import { assertResultMatch, TestSuite } from "../testUtils";
import setupClient from "../setupClient";
import { assertResultMatch, addressTests } from "../testUtils";
const instructionsWithMaxLedgerVersionOffset = { maxLedgerVersionOffset: 100 };
/**
* 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>{
async prepareCheckCreate(client, address, mockRippled) {
mockRippled.addResponse("server_info", rippled.server_info.normal);
mockRippled.addResponse("fee", rippled.fee);
mockRippled.addResponse("ledger_current", rippled.ledger_current);
mockRippled.addResponse("account_info", rippled.account_info.normal);
const localInstructions = {
...instructionsWithMaxLedgerVersionOffset,
maxFee: "0.000012",
};
const result = await client.prepareCheckCreate(
address,
requests.prepareCheckCreate.normal,
localInstructions
);
assertResultMatch(result, responses.prepareCheckCreate.normal, "prepare");
},
describe("client.prepareCheckCreate", function () {
beforeEach(setupClient.setup);
afterEach(setupClient.teardown);
"prepareCheckCreate full": async (client, address, mockRippled) => {
mockRippled.addResponse("server_info", rippled.server_info.normal);
mockRippled.addResponse("fee", rippled.fee);
mockRippled.addResponse("ledger_current", rippled.ledger_current);
mockRippled.addResponse("account_info", rippled.account_info.normal);
const result = await client.prepareCheckCreate(
address,
requests.prepareCheckCreate.full
);
assertResultMatch(result, responses.prepareCheckCreate.full, "prepare");
},
addressTests.forEach(function (test) {
describe(test.type, function () {
it("prepareCheckCreate", async function () {
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
this.mockRippled.addResponse("fee", rippled.fee);
this.mockRippled.addResponse("ledger_current", rippled.ledger_current);
this.mockRippled.addResponse(
"account_info",
rippled.account_info.normal
);
const localInstructions = {
...instructionsWithMaxLedgerVersionOffset,
maxFee: "0.000012",
};
const result = await this.client.prepareCheckCreate(
test.address,
requests.prepareCheckCreate.normal,
localInstructions
);
assertResultMatch(
result,
responses.prepareCheckCreate.normal,
"prepare"
);
});
"prepareCheckCreate with ticket": async (client, address, mockRippled) => {
mockRippled.addResponse("server_info", rippled.server_info.normal);
mockRippled.addResponse("fee", rippled.fee);
mockRippled.addResponse("ledger_current", rippled.ledger_current);
mockRippled.addResponse("account_info", rippled.account_info.normal);
const localInstructions = {
...instructionsWithMaxLedgerVersionOffset,
maxFee: "0.000012",
ticketSequence: 23,
};
const result = await client.prepareCheckCreate(
address,
requests.prepareCheckCreate.normal,
localInstructions
);
assertResultMatch(result, responses.prepareCheckCreate.ticket, "prepare");
},
};
it("prepareCheckCreate full", async function () {
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
this.mockRippled.addResponse("fee", rippled.fee);
this.mockRippled.addResponse("ledger_current", rippled.ledger_current);
this.mockRippled.addResponse(
"account_info",
rippled.account_info.normal
);
const result = await this.client.prepareCheckCreate(
test.address,
requests.prepareCheckCreate.full
);
assertResultMatch(result, responses.prepareCheckCreate.full, "prepare");
});
it("prepareCheckCreate with ticket", async function () {
this.mockRippled.addResponse("server_info", rippled.server_info.normal);
this.mockRippled.addResponse("fee", rippled.fee);
this.mockRippled.addResponse("ledger_current", rippled.ledger_current);
this.mockRippled.addResponse(
"account_info",
rippled.account_info.normal
);
const localInstructions = {
...instructionsWithMaxLedgerVersionOffset,
maxFee: "0.000012",
ticketSequence: 23,
};
const result = await this.client.prepareCheckCreate(
test.address,
requests.prepareCheckCreate.normal,
localInstructions
);
assertResultMatch(
result,
responses.prepareCheckCreate.ticket,
"prepare"
);
});
});
});
});