-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
125 lines (102 loc) · 3.04 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* jshint esversion: 6 */
/*global assert */
(function() {
"use strict";
const listOfAccounts =[];
/**
* Now lets create two saving accounts with interest rate 2%
* @type {SavingsAccount}
*/
const savingsAccount = new SavingsAccount(1,2);
/**
* Deposit 100$
* @type {SavingsAccount}
*/
savingsAccount.deposit(100);
/**
* calculate interest
* @type {SavingsAccount}
* we expect the total balance to be 100+100*2/100 = $102
*/
savingsAccount.addInterest();
/**
* now lets us withdraw some money $40
* the expected balance is $62
*/
savingsAccount.withdraw(40);
/**
* Moch, Chai test for the Saving Account
*/
describe("Saving Account Test", function() {
context("Account number: 1, Initial deposit $100, Interest rate 2%, Interest added! and $40 withdrawed ", function() {
it("The expected Balance is $62", function() {
assert.equal(savingsAccount.getBalance(),62);
});
});
});
/**
* now lets us create some CheckingAccounts.
* Checking accounts with $120 overdraft limit
* @type {SavingsAccount}
*/
const checkingAccount = new CheckingAccount(1 , 120);
/**
* Put some money in the account
* @type {SavingsAccount}
*/
checkingAccount.deposit(50);
/**
* lets now withdraw $110, the expected balance is -$60
* @type {SavingsAccount}
*/
checkingAccount.withdraw(110);
/**
* lets now check the account to see how much money it has in mocha test
* we expect -$60
* @type {SavingsAccount}
*/
describe("Checking Account Test", function() {
context("Account number: 1, Initial deposit $50, Overdraft Limit $120, withdrawn $110, expected to remain is -$60", function() {
it("The expected Balance is $-60", function() {
assert.equal(checkingAccount.getBalance(),-60);
});
});
});
/**
* Now lets create a Bank object and insert some accounts
*
*/
const bank = new Bank();
bank.addSavingsAccount(9);
/**
* now lets us create a simple account
* we expect the account to be added into
* an array in the bank object
*
*/
bank.addAccount();
/**
* lets now create a saving account
* with interest rate 3%
*
*/
bank.addSavingsAccount(3);
/**
* lets now create checking account with overdraft limit
* $120
*/
bank.addCheckingAccount(120);
/**
* lets now see all information about the different types of accounts
* in the bank in the Mocha test
*/
describe("Bank Class Test", function() {
context("Account with acct No =1 \n" +
"Saving Account with acct No = 2 and interest rate 3%\n" +
"Checking Account with acct No = 3 and overdraft limit 120", function() {
it("", function() {
assert.equal(checkingAccount.getBalance(),-60);
});
});
});
}());