From b0bad44a9ecc01ab780cc42527e6121374b3bcef Mon Sep 17 00:00:00 2001 From: billcuthbert <96billc@gmail.com> Date: Mon, 16 Aug 2021 02:01:24 +0100 Subject: [PATCH] tests --- src/app/app.component.html | 42 +++++++------- src/app/app.component.spec.ts | 13 ----- src/app/app.component.ts | 20 +------ src/app/model.ts | 21 +++++-- .../transaction-form.component.html | 21 +++---- .../transaction-form.component.spec.ts | 58 +++++++++++++++++-- .../transaction-form.component.ts | 7 +-- .../transaction-list.component.html | 2 +- .../transaction-list.component.scss | 3 +- .../transaction-list.component.spec.ts | 55 +++++++++++++----- .../transaction-list.component.ts | 2 +- 11 files changed, 151 insertions(+), 93 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 79ec5ae..dc2692d 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,26 +1,28 @@ -
- -
-
-
-
-
-
-
- -

Make Transfer

+
+
+ +
+
+
+
+
+
+
+ +

Make Transfer

+
+
- -
-
-
- -

Transactions List

+
+
+ +

Transactions List

+
+
-
-
- \ No newline at end of file + +
\ No newline at end of file diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index d7e2f27..27a9448 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -15,17 +15,4 @@ describe('AppComponent', () => { const app = fixture.componentInstance; expect(app).toBeTruthy(); }); - - it(`should have as title 'backbase-app'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('backbase-app'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement; - expect(compiled.querySelector('.content span').textContent).toContain('backbase-app app is running!'); - }); }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index ff79582..66f2e64 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -13,24 +13,6 @@ export class AppComponent { transaction!: Transaction recieveTransfer(event: Transfer) { - this.transaction = { - id: "", - categoryCode: "#d9bcf5", - dates: { - valueDate: Date.now() - }, - transaction: { - amountCurrency: { - amount: event.amount, - currencyCode: "EUR" - }, - type: "New Transfer", - creditDebitIndicator: "DBIT" - }, - merchant: { - name: event.account, - accountNumber: "" - } - } + this.transaction = new Transaction(event.amount, "New Transfer", event.account) } } diff --git a/src/app/model.ts b/src/app/model.ts index caac7c7..74f7b61 100644 --- a/src/app/model.ts +++ b/src/app/model.ts @@ -1,9 +1,9 @@ -export interface Transaction { - id: string | null, - categoryCode: string, +export class Transaction { + id!: string; + categoryCode: string; dates: { valueDate: string | number - }, + }; transaction: { amountCurrency: { amount: number, @@ -11,11 +11,22 @@ export interface Transaction { }, type: string, creditDebitIndicator: string - }, + }; merchant: { name: string, accountNumber: string } + + constructor(tAmount?: number, tType?: string, merchantName?: string, date?: number) { + this.categoryCode = "#d9bcf5" + this.dates = { valueDate: date ? date : 1234 } + this.transaction = { + amountCurrency: { amount: tAmount || 0, currencyCode: "EUR" }, + type: tType || "New Transfer", + creditDebitIndicator: "DBIT" + } + this.merchant = { name: merchantName || "Merchant", accountNumber: "" } + } } export interface Transfer { diff --git a/src/app/transaction-form/transaction-form.component.html b/src/app/transaction-form/transaction-form.component.html index 0e8e8e0..805a87b 100644 --- a/src/app/transaction-form/transaction-form.component.html +++ b/src/app/transaction-form/transaction-form.component.html @@ -8,8 +8,9 @@
- + [ngClass]="{ 'is-invalid': isControlInvalid(transactionForm.controls.toAcc) }"> +
@@ -17,13 +18,13 @@
- +
-
- - - +
+ + +
@@ -41,9 +42,9 @@