-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
151 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
<div class="pt-4 px-3"> | ||
<app-logo></app-logo> | ||
</div> | ||
<div class="background mt-4"> | ||
<div class="unblur pt-2"> | ||
<div class="container"> | ||
<div class="mt-3 mb-2 pb-4 row justify-content-md-center"> | ||
<div class="col-lg-4 pb-3"> | ||
<div class="blue-header card-header"> | ||
<i class="lni lni-wallet"></i> | ||
<h4 class="pl-3 d-inline">Make Transfer</h4> | ||
<div class="app"> | ||
<div class="pt-4 px-3"> | ||
<app-logo></app-logo> | ||
</div> | ||
<div class="background mt-4"> | ||
<div class="unblur pt-2"> | ||
<div class="container"> | ||
<div class="mt-3 mb-2 pb-4 row justify-content-center"> | ||
<div class="col-lg-4 pb-3"> | ||
<div class="blue-header card-header"> | ||
<i class="lni lni-wallet"></i> | ||
<h4 class="pl-3 d-inline">Make Transfer</h4> | ||
</div> | ||
<app-transaction-form (newTransfer)="recieveTransfer($event)"></app-transaction-form> | ||
</div> | ||
<app-transaction-form (newTransfer)="recieveTransfer($event)"></app-transaction-form> | ||
</div> | ||
<div class="col-lg-8"> | ||
<div class="blue-header card-header"> | ||
<i class="lni lni-list"></i> | ||
<h4 class="pl-3 d-inline">Transactions List</h4> | ||
<div class="col-lg-8"> | ||
<div class="blue-header card-header"> | ||
<i class="lni lni-list"></i> | ||
<h4 class="pl-3 d-inline">Transactions List</h4> | ||
</div> | ||
<app-transaction-list [newTransaction]="transaction"></app-transaction-list> | ||
</div> | ||
<app-transaction-list [newTransaction]="transaction"></app-transaction-list> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<app-footer></app-footer> | ||
<app-footer></app-footer> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 54 additions & 4 deletions
58
src/app/transaction-form/transaction-form.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,75 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { FormBuilder } from '@angular/forms'; | ||
import { By } from '@angular/platform-browser'; | ||
import { SubmitButtonComponent } from 'bb-ui/components/submit-button/submit-button.component'; | ||
import { collapseTextChangeRangesAcrossMultipleVersions } from 'typescript'; | ||
|
||
import { TransactionFormComponent } from './transaction-form.component'; | ||
|
||
describe('TransactionFormComponent', () => { | ||
let component: TransactionFormComponent; | ||
let component2: ComponentFixture<SubmitButtonComponent>; | ||
|
||
let fixture: ComponentFixture<TransactionFormComponent>; | ||
let fixture2: ComponentFixture<SubmitButtonComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ TransactionFormComponent ] | ||
}) | ||
.compileComponents(); | ||
declarations: [TransactionFormComponent, SubmitButtonComponent], | ||
providers: [FormBuilder] | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TransactionFormComponent); | ||
fixture2 = TestBed.createComponent(SubmitButtonComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
it('should create the TransactionFormComponent', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should display validation errors if controls are empty on submit', () => { | ||
component.transactionForm.controls.amount.setValue("") | ||
component.transactionForm.controls.toAcc.setValue("") | ||
component.submitClicked = true | ||
fixture.detectChanges() | ||
|
||
expect(component.transactionForm.valid).toBeFalsy() | ||
expect(fixture.debugElement.queryAll(By.css('.error')).length).toBe(2) | ||
}); | ||
|
||
it('should not display validation errors if controls are valid', () => { | ||
component.transactionForm.controls.amount.setValue("123") | ||
component.transactionForm.controls.toAcc.setValue("test account") | ||
fixture.detectChanges() | ||
|
||
expect(component.transactionForm.valid).toBeTruthy() | ||
expect(fixture.debugElement.queryAll(By.css('.error')).length).toBe(0) | ||
}); | ||
|
||
xit('should display validation errors if amount field is too large on submit', () => { | ||
component.userBalance = 5000 | ||
component.transactionForm.controls.toAcc.setValue("test account") | ||
component.transactionForm.controls.amount.setValue(5501) | ||
component.transactionForm.updateValueAndValidity() | ||
component.submitClicked = true | ||
|
||
fixture.detectChanges() | ||
|
||
expect(component.transactionForm.invalid).toBeTruthy() | ||
expect(fixture.debugElement.queryAll(By.css('.error')).length).toBe(1) | ||
}); | ||
|
||
it('should display validation errors if amount field is negative on submit', () => { | ||
component.transactionForm.controls.toAcc.setValue("test account") | ||
component.transactionForm.controls.amount.setValue("-1") | ||
component.submitClicked = true | ||
fixture.detectChanges() | ||
|
||
expect(component.transactionForm.valid).toBeFalsy() | ||
expect(fixture.debugElement.queryAll(By.css('.error')).length).toBe(1) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 40 additions & 15 deletions
55
src/app/transaction-list/transaction-list.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
import { HttpClient, HttpHandler } from '@angular/common/http'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { By } from '@angular/platform-browser'; | ||
import { Transaction } from '../model'; | ||
import { TransactionListComponent } from './transaction-list.component'; | ||
|
||
describe('TransactionListComponent', () => { | ||
let component: TransactionListComponent; | ||
let fixture: ComponentFixture<TransactionListComponent>; | ||
let component: TransactionListComponent | ||
let fixture: ComponentFixture<TransactionListComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ TransactionListComponent ] | ||
}) | ||
.compileComponents(); | ||
}); | ||
declarations: [TransactionListComponent], | ||
providers: [HttpClient, HttpHandler] | ||
}).compileComponents() | ||
}) | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(TransactionListComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
fixture = TestBed.createComponent(TransactionListComponent) | ||
component = fixture.componentInstance | ||
fixture.detectChanges() | ||
}) | ||
|
||
it('should create the TransactionListComponent', () => { | ||
expect(component).toBeTruthy() | ||
}) | ||
|
||
it('should display a list entry for each transaction', () => { | ||
component.transactions = [new Transaction(1), new Transaction(2), new Transaction(3)] | ||
fixture.detectChanges() | ||
expect(fixture.debugElement.queryAll(By.css('.list-group-item')).length).toBe(3) | ||
}) | ||
|
||
it('should add a transaction to the list if the @Input is updated and ngOnChanges is called', () => { | ||
component.transactions = [new Transaction(1), new Transaction(2), new Transaction(3)] | ||
component.newTransaction = new Transaction(4) | ||
component.ngOnChanges() | ||
fixture.detectChanges() | ||
expect(fixture.debugElement.queryAll(By.css('.list-group-item')).length).toBe(4) | ||
}) | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); | ||
xit('should sort the transactions by date', () => { | ||
component.transactions = [new Transaction(1, "", "", 0), new Transaction(2, "", "", 86400), new Transaction(3, "", "", 172800)] | ||
fixture.detectChanges() | ||
const list = fixture.debugElement.queryAll(By.css('.date')) | ||
for (let i = 0; i < 3; i++) { | ||
expect(list[i].nativeNode.innerHTML).toContain("Jan " + (i + 1)) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters