refactor: move fixtures closer to tests (part 2) (#1561)

* move echo

* move fee

* move subscribe/unsubscribe

* move ledger_current

* move ledger_data

* move submit/submit_multisigned

* remove account_tx/account_offers/gateway_balances

* move account_info

* remove ledger_entry

* remove tx

* remove account_lines

* remove ripple_path_find

* remove ledger

* remove book_offers

* move ping

* remove global_config

* move test_command

* additional mock-rippled cleanup

* add explanatory comment to mock.addResponse
This commit is contained in:
Mayukha Vadari
2021-08-26 14:02:48 -04:00
parent f9fe5936b1
commit 09ef8595e7
31 changed files with 657 additions and 752 deletions

View File

@@ -1,5 +1,6 @@
import assert from 'assert-diff'
import {TestSuite} from '../testUtils'
import rippled from '../fixtures/rippled'
/**
* Every test suite exports their tests in the default object.
@@ -7,13 +8,22 @@ import {TestSuite} from '../testUtils'
* - Check out "test/client/index.ts" for more information about the test runner.
*/
export default <TestSuite>{
'returns true when there is another page': async (client, address) => {
'returns true when there is another page': async (client, address, mockRippled) => {
mockRippled.addResponse({command: 'ledger_data'}, rippled.ledger_data.first_page)
// @ts-ignore
const response = await client.request({command: 'ledger_data'})
assert(client.hasNextPage(response))
},
'returns false when there are no more pages': async (client, address) => {
'returns false when there are no more pages': async (client, address, mockRippled) => {
const rippledResponse = function(request: Request) : object {
if ('marker' in request) {
return rippled.ledger_data.last_page
} else {
return rippled.ledger_data.first_page
}
}
mockRippled.addResponse({command: 'ledger_data'}, rippledResponse)
// @ts-ignore
const response = await client.request({command: 'ledger_data'})
const responseNextPage = await client.requestNextPage(