fix bank API test

This commit is contained in:
Florian Dold 2020-09-06 18:24:33 +05:30
parent 7863bcbcaf
commit 92873710f1
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 12 additions and 10 deletions

View File

@ -564,8 +564,10 @@ export enum CreditDebitIndicator {
}
export interface BankAccountBalanceResponse {
amount: AmountString;
credit_debit_indicator: CreditDebitIndicator;
balance: {
amount: AmountString;
credit_debit_indicator: CreditDebitIndicator;
};
}
export namespace BankAccessApi {
@ -573,7 +575,7 @@ export namespace BankAccessApi {
bank: BankServiceInterface,
bankUser: BankUser,
): Promise<BankAccountBalanceResponse> {
const url = new URL(`accounts/${bankUser.username}/balance`, bank.baseUrl);
const url = new URL(`accounts/${bankUser.username}`, bank.baseUrl);
const resp = await axios.get(url.href, {
auth: bankUser,
});

View File

@ -113,13 +113,13 @@ runTest(async (t: GlobalTestState) => {
t.assertTrue(e.response?.status === 409);
}
let bal = await BankAccessApi.getAccountBalance(bank, bankUser);
let balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
console.log(bal);
console.log(balResp);
// Check that we got the sign-up bonus.
t.assertAmountEquals(bal.amount, "TESTKUDOS:100");
t.assertTrue(bal.credit_debit_indicator === CreditDebitIndicator.Credit);
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:100");
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Credit);
const res = createEddsaKeyPair();
@ -130,7 +130,7 @@ runTest(async (t: GlobalTestState) => {
reservePub: encodeCrock(res.eddsaPub),
});
bal = await BankAccessApi.getAccountBalance(bank, bankUser);
t.assertAmountEquals(bal.amount, "TESTKUDOS:15");
t.assertTrue(bal.credit_debit_indicator === CreditDebitIndicator.Debit);
balResp = await BankAccessApi.getAccountBalance(bank, bankUser);
t.assertAmountEquals(balResp.balance.amount, "TESTKUDOS:15");
t.assertTrue(balResp.balance.credit_debit_indicator === CreditDebitIndicator.Debit);
});