-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAction.test.js
64 lines (48 loc) · 1.25 KB
/
Action.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
const Action = require("./Action");
describe(Action, () => {
const date = new Date().toLocaleDateString();
it("updates balance after deposit", () => {
const action = new Action();
expect(action.deposit(10, 0)).toEqual(
expect.objectContaining({balance: 10})
)
})
it("updates balance after withdrawal", () => {
const action = new Action();
expect(action.withdraw(10, 15)).toEqual(
expect.objectContaining({balance: 5})
)
})
it("creates statement for deposit", () => {
const action = new Action();
const deposit = action.deposit(5, 0);
expect(deposit).toEqual({
date: date,
credit: 5,
debit: null,
balance: 5,
})
})
it("creates statement for withdrawal", () => {
const action = new Action();
const withdraw = action.withdraw(10, 10);
expect(withdraw).toEqual({
date: date,
credit: null,
debit: 10,
balance: 0,
})
})
it("doesn't allow user to withdraw money they don't have", () => {
const action = new Action();
const withdraw = action.withdraw(30, 20);
expect(action.balance).toBe(0);
expect(withdraw).toEqual(
{ date: date,
credit: null,
debit: 20,
balance: 0,
}
)
})
})