peter-miklos / bank_tech_test_js

Bank tech test in Javascript - Program lets user to create an account, make debit and credit transactions, print a statement and it manages balance too

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bank Tech Test in Javascript

Description:

The program acts as a simple account keeping solution. It lets user to create an account, make debit and credit transactions, and print a statement. The program manages the current balance as well.

Instructions for how to run the program

$ git clone https://github.com/peter-miklos/bank_tech_test_js.git
$ open SpecRunner.html

Use Chrome Console to interact with the code. User stories

As a User
So that I can manage my financials
I want to open an account

As a User
So that I can use the money on my account
I want to make credit and debit transactions

As a User
So that I can plan my future spending and check transaction history
I want to see an account statement

Tests

Feature tests

The program's main features are tested in Chrome Console:

account = new Account
  Account {_OPENING_BALANCE: 0, _balance: 0, _transactionLog: TransactionLog, _statementEngine: StatementEngine}
account.deposit(1000)
  undefined
account.deposit(200)
  undefined
account.printStatement()
  "date || credit || debit || balance
  12/10/2016 || 200.00 || || 1200.00
  12/10/2016 || 1000.00 || || 1000.00"
account.withdraw(333)
  undefined
account.printStatement()
  "date || credit || debit || balance
  12/10/2016 || || 333.00 || 867.00
  12/10/2016 || 200.00 || || 1200.00
  12/10/2016 || 1000.00 || || 1000.00"

Unit tests

The following unit tests are used:

Account
  #deposit
    calls the deposit method on transactionLog
    adds the amount to the current balance
  #withdraw
    calls the withdraw method on transactionLog
    deducts the amount from the current balance
  #printStatement
    calls the printStatement method on StatementEngine
    returns the value received from StatementEngine
StatementEngine
  #printStatement
    returns the statement with header
Transaction
  #amount
    returns the value of the credit transaction
    returns the value of the debit transaction
  #balance
    returns the new balance after credit transaction booked
    returns the new balance after debit transaction booked
  #type
    returns the type of the credit transaction
    returns the type of the debit transaction
  #date
    returns the date of the credit transaction
    returns the date of the debit transaction
TransactionLog
  #deposit
    create credit transaction and add it to transactions array
    raises error if amount is not an integer
    raises error if amount is equal or less than zero
  #withdraw
    create debit transaction and add it to transactions array
    raises error if amount is not an integer
    raises error if amount is equal or less than zero
    raises error if balance is less than zero
  #getTransactions
    returns a copy of transactions

About

Bank tech test in Javascript - Program lets user to create an account, make debit and credit transactions, print a statement and it manages balance too


Languages

Language:JavaScript 99.3%Language:HTML 0.7%