mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-19 19:55:51 +00:00
* better error handling + tests * fix tests * change addResponse to take a string instead of a Request * remove unneeded change * respond to comments * fix tests, re-lint * improve error message
37 lines
1021 B
TypeScript
37 lines
1021 B
TypeScript
import { assert } from "chai";
|
|
|
|
import { RippledError } from "../src/common/errors";
|
|
|
|
import setupClient from "./setupClient";
|
|
import { assertRejects } from "./testUtils";
|
|
|
|
describe("mock rippled tests", function () {
|
|
beforeEach(setupClient.setup);
|
|
afterEach(setupClient.teardown);
|
|
it("errors if a mock is not provided", async function () {
|
|
this.mockRippled.suppressOutput = true;
|
|
await assertRejects(
|
|
this.client.request({ command: "server_info" }),
|
|
RippledError
|
|
);
|
|
});
|
|
|
|
it("provide bad response shape", async function () {
|
|
assert.throws(
|
|
() => this.mockRippled.addResponse("account_info", { data: {} }),
|
|
Error
|
|
);
|
|
});
|
|
|
|
it("provide bad response shape in function", async function () {
|
|
this.mockRippled.suppressOutput = true;
|
|
this.mockRippled.addResponse("account_info", (request) => {
|
|
return { data: request };
|
|
});
|
|
await assertRejects(
|
|
this.client.request({ command: "account_info", account: "" }),
|
|
RippledError
|
|
);
|
|
});
|
|
});
|