mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +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:
@@ -3,7 +3,8 @@ import { assert } from "chai";
|
||||
import addresses from "../fixtures/addresses.json";
|
||||
import requests from "../fixtures/requests";
|
||||
import rippled from "../fixtures/rippled";
|
||||
import { assertRejects, TestSuite } from "../testUtils";
|
||||
import setupClient from "../setupClient";
|
||||
import { assertRejects } from "../testUtils";
|
||||
// import responses from '../fixtures/responses'
|
||||
const { getPaths: REQUEST_FIXTURES } = requests;
|
||||
// const {getPaths: RESPONSE_FIXTURES} = responses
|
||||
@@ -15,97 +16,94 @@ const rippledResponse = rippled.path_find.generate.generateIOUPaymentPaths(
|
||||
REQUEST_FIXTURES.normal.destination.amount
|
||||
);
|
||||
|
||||
/**
|
||||
* 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>{
|
||||
// 'simple test': async (client) => {
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.normal)
|
||||
describe("client.getPaths", function () {
|
||||
beforeEach(setupClient.setup);
|
||||
afterEach(setupClient.teardown);
|
||||
// 'simple test', function () {
|
||||
// const response = await this.client.getPaths(REQUEST_FIXTURES.normal)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToUsd, 'getPaths')
|
||||
// },
|
||||
// 'queuing': async (client) => {
|
||||
// })
|
||||
// 'queuing', function () {
|
||||
// const [normalResult, usdOnlyResult, xrpOnlyResult] = await Promise.all([
|
||||
// client.getPaths(REQUEST_FIXTURES.normal),
|
||||
// client.getPaths(REQUEST_FIXTURES.UsdToUsd),
|
||||
// client.getPaths(REQUEST_FIXTURES.XrpToXrp)
|
||||
// this.client.getPaths(REQUEST_FIXTURES.normal),
|
||||
// this.client.getPaths(REQUEST_FIXTURES.UsdToUsd),
|
||||
// this.client.getPaths(REQUEST_FIXTURES.XrpToXrp)
|
||||
// ])
|
||||
// assertResultMatch(normalResult, RESPONSE_FIXTURES.XrpToUsd, 'getPaths')
|
||||
// assertResultMatch(usdOnlyResult, RESPONSE_FIXTURES.UsdToUsd, 'getPaths')
|
||||
// assertResultMatch(xrpOnlyResult, RESPONSE_FIXTURES.XrpToXrp, 'getPaths')
|
||||
// },
|
||||
// })
|
||||
// // @TODO
|
||||
// // need decide what to do with currencies/XRP:
|
||||
// // if add 'XRP' in currencies, then there will be exception in
|
||||
// // xrpToDrops function (called from toRippledAmount)
|
||||
// 'getPaths USD 2 USD': async (client) => {
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.UsdToUsd)
|
||||
// 'getPaths USD 2 USD', function () {
|
||||
// const response = await this.client.getPaths(REQUEST_FIXTURES.UsdToUsd)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.UsdToUsd, 'getPaths')
|
||||
// },
|
||||
// 'getPaths XRP 2 XRP': async (client) => {
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.XrpToXrp)
|
||||
// })
|
||||
// 'getPaths XRP 2 XRP', function () {
|
||||
// const response = await this.client.getPaths(REQUEST_FIXTURES.XrpToXrp)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.XrpToXrp, 'getPaths')
|
||||
// },
|
||||
"source with issuer": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
// })
|
||||
it("source with issuer", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.issuer),
|
||||
client.errors.NotFoundError
|
||||
this.client.getPaths(REQUEST_FIXTURES.issuer),
|
||||
this.client.errors.NotFoundError
|
||||
);
|
||||
},
|
||||
// 'XRP 2 XRP - not enough': async (client) => {
|
||||
});
|
||||
// 'XRP 2 XRP - not enough', function () {
|
||||
// return assertRejects(
|
||||
// client.getPaths(REQUEST_FIXTURES.XrpToXrpNotEnough),
|
||||
// client.errors.NotFoundError
|
||||
// this.client.getPaths(REQUEST_FIXTURES.XrpToXrpNotEnough),
|
||||
// this.client.errors.NotFoundError
|
||||
// )
|
||||
// },
|
||||
"invalid PathFind": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
// })
|
||||
it("invalid PathFind", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
assert.throws(() => {
|
||||
client.getPaths(REQUEST_FIXTURES.invalid);
|
||||
this.client.getPaths(REQUEST_FIXTURES.invalid);
|
||||
}, /Cannot specify both source.amount/);
|
||||
},
|
||||
"does not accept currency": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
});
|
||||
it("does not accept currency", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NotAcceptCurrency),
|
||||
client.errors.NotFoundError
|
||||
this.client.getPaths(REQUEST_FIXTURES.NotAcceptCurrency),
|
||||
this.client.errors.NotFoundError
|
||||
);
|
||||
},
|
||||
"no paths": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
});
|
||||
it("no paths", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPaths),
|
||||
client.errors.NotFoundError
|
||||
this.client.getPaths(REQUEST_FIXTURES.NoPaths),
|
||||
this.client.errors.NotFoundError
|
||||
);
|
||||
},
|
||||
"no paths source amount": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
});
|
||||
it("no paths source amount", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPathsSource),
|
||||
client.errors.NotFoundError
|
||||
this.client.getPaths(REQUEST_FIXTURES.NoPathsSource),
|
||||
this.client.errors.NotFoundError
|
||||
);
|
||||
},
|
||||
"no paths with source currencies": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
});
|
||||
it("no paths with source currencies", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths(REQUEST_FIXTURES.NoPathsWithCurrencies),
|
||||
client.errors.NotFoundError
|
||||
this.client.getPaths(REQUEST_FIXTURES.NoPathsWithCurrencies),
|
||||
this.client.errors.NotFoundError
|
||||
);
|
||||
},
|
||||
"error: srcActNotFound": async (client, _, mockRippled) => {
|
||||
mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
});
|
||||
it("error: srcActNotFound", function () {
|
||||
this.mockRippled.addResponse("ripple_path_find", rippledResponse);
|
||||
return assertRejects(
|
||||
client.getPaths({
|
||||
this.client.getPaths({
|
||||
...REQUEST_FIXTURES.normal,
|
||||
source: { address: addresses.NOTFOUND },
|
||||
}),
|
||||
client.errors.RippleError
|
||||
this.client.errors.RippleError
|
||||
);
|
||||
},
|
||||
// 'send all': async (client) => {
|
||||
// const response = await client.getPaths(REQUEST_FIXTURES.sendAll)
|
||||
});
|
||||
// 'send all', function () {
|
||||
// const response = await this.client.getPaths(REQUEST_FIXTURES.sendAll)
|
||||
// assertResultMatch(response, RESPONSE_FIXTURES.sendAll, 'getPaths')
|
||||
// }
|
||||
};
|
||||
// })
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user