Giter VIP home page Giter VIP logo

bank_tech_test_js's Introduction

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

bank_tech_test_js's People

Contributors

peter-miklos avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.