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 { export interface BankAccountBalanceResponse {
amount: AmountString; balance: {
credit_debit_indicator: CreditDebitIndicator; amount: AmountString;
credit_debit_indicator: CreditDebitIndicator;
};
} }
export namespace BankAccessApi { export namespace BankAccessApi {
@ -573,7 +575,7 @@ export namespace BankAccessApi {
bank: BankServiceInterface, bank: BankServiceInterface,
bankUser: BankUser, bankUser: BankUser,
): Promise<BankAccountBalanceResponse> { ): 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, { const resp = await axios.get(url.href, {
auth: bankUser, auth: bankUser,
}); });

View File

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