mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-03 10:35:49 +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,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"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user