|
| 1 | +import { describe, test, expect } from "@jest/globals"; |
| 2 | +import { |
| 3 | + API, |
| 4 | + Version, |
| 5 | + APIClientConfig, |
| 6 | + DirectLoginAuthentication, |
| 7 | + create, |
| 8 | + get, |
| 9 | + Transaction, |
| 10 | +} from "../src/api"; |
| 11 | +import { |
| 12 | + GetTransactionsForAccountFull, |
| 13 | + CreateTransactionRequestAccount, |
| 14 | + TransactionRequestAccountBody, |
| 15 | +} from "../src/api/transaction"; |
| 16 | + |
| 17 | +const directLogin: DirectLoginAuthentication = { |
| 18 | + username: global.obpUsername, |
| 19 | + password: global.obpPassword, |
| 20 | + consumerKey: global.obpConsumerKey, |
| 21 | +}; |
| 22 | +const clientConfig: APIClientConfig = { |
| 23 | + baseUri: global.obpBaseUri, |
| 24 | + version: global.obpVersion as Version, |
| 25 | + authentication: directLogin, |
| 26 | +}; |
| 27 | +const bankId = global.obpTestBankId; |
| 28 | +const accountId = "9e6b2f45-a449-4e87-b772-e74cc9d42448"; |
| 29 | +const viewId = "owner"; |
| 30 | + |
| 31 | +describe("Transaction", () => { |
| 32 | + test("get<API.Transaction> ByBankId should be able to get the OBP Transactions data.", async () => { |
| 33 | + const transactions = await get<API.Transaction>( |
| 34 | + clientConfig, |
| 35 | + Transaction |
| 36 | + )(GetTransactionsForAccountFull)(bankId, accountId, viewId); |
| 37 | + |
| 38 | + expect(transactions).toBeDefined(); |
| 39 | + }); |
| 40 | + |
| 41 | + test("get<API.Transaction> should be able to get the OBP Transactions data.", async () => { |
| 42 | + const transactions = await get<API.Transaction>( |
| 43 | + clientConfig, |
| 44 | + Transaction |
| 45 | + )(`/banks/${bankId}/accounts/${accountId}/${viewId}/transactions`); |
| 46 | + |
| 47 | + expect(transactions).toBeDefined(); |
| 48 | + }); |
| 49 | + |
| 50 | + test("create<API.Transaction, TransactionFullBody> should be able to createn an OBP Transaction Full data.", async () => { |
| 51 | + const body: TransactionRequestAccountBody = { |
| 52 | + description: "test transaction full data", |
| 53 | + to: { |
| 54 | + bank_id: bankId, |
| 55 | + account_id: accountId, |
| 56 | + }, |
| 57 | + value: { |
| 58 | + currency: "EUR", |
| 59 | + amount: 1.0, |
| 60 | + }, |
| 61 | + }; |
| 62 | + const transactions = await create<API.Transaction>( |
| 63 | + clientConfig, |
| 64 | + Transaction |
| 65 | + )(CreateTransactionRequestAccount)( |
| 66 | + bankId, |
| 67 | + accountId, |
| 68 | + viewId, |
| 69 | + "SANDBOX_TAN" |
| 70 | + )(body); |
| 71 | + |
| 72 | + expect(transactions).toBeDefined(); |
| 73 | + }); |
| 74 | +}); |
0 commit comments