Skip to content

Commit 6414904

Browse files
committed
added bank account
1 parent a7fdf1c commit 6414904

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

chapter1/bank-account.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var BankSecurity = {
2+
foo: 42
3+
}
4+
5+
var BankAccount = {
6+
balance: 0,
7+
deposit: function (money) {
8+
this.balance = this.balance + money;
9+
},
10+
widthraw: function (cash) {
11+
this.balance = this.balance - cash;
12+
return this.balance;
13+
}
14+
};
15+
16+
module.exports = {
17+
BankAccount: BankAccount,
18+
BankSecurity: BankSecurity
19+
}
20+
21+

chapter1/test/bank-account.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var assert = require('assert');
2+
var BankAccount = require('../bank-account').BankAccount;
3+
4+
describe('Bank account', () => {
5+
it('should have no money on deposit in the beginning', () => {
6+
7+
var obj = {
8+
foo: "hello world",
9+
fn: function () {
10+
console.log(this.foo.split(''));
11+
}
12+
}
13+
14+
var boo = obj.fn;
15+
console.log(boo());
16+
//assert.equal(BankAccount.balance, 0);
17+
});
18+
})

chapter1/test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var assert = require('assert');
22

3-
describe('JS Basics', function() {
3+
xdescribe('JS Basics', function() {
44
describe('Numbers', function() {
55
it('should be able to add number', function() {
66
var a = 42.9902822;

0 commit comments

Comments
 (0)