git ssb

0+

Rômulo Alves / money-block



Tree: 2d09c616b9a763b1a6c1fe7103b642ee98d5c1c0

Files: 2d09c616b9a763b1a6c1fe7103b642ee98d5c1c0 / tests / index.test.js

2986 bytesRaw
1const test = require('ava');
2
3const { readMock } = require('./helpers/mock');
4const moneyBlockProcess = require('../src/index');
5
6test('single group', function(t) {
7 const data = readMock('single-group.txt');
8 const expected = `$ 234
9
10| savings account
11+ 123 first deposit
12+ 111 second deposit
13= 234
14`;
15
16 const response = moneyBlockProcess(data);
17
18 t.is(response, expected);
19});
20
21test('two groups', function(t) {
22 const data = readMock('two-groups.txt');
23 const expected = `$ 1480.53
24
25| savings account
26+ 123 first deposit
27+ 111 second deposit
28= 234
29
30| investing
31+ 1240 first deposit
32+ 2.40 second deposit
33+ 4.13 investing hard!
34= 1246.53
35`;
36
37 const response = moneyBlockProcess(data);
38
39 t.is(response, expected);
40});
41
42test('four groups', function(t) {
43 const data = readMock('four-groups.txt');
44 const expected = `$ 12402867.05
45
46| savings account
47+ 123 first deposit
48+ 111 second deposit
49- 29.48 wasting money
50+ 400 saved a lot!!!
51= 604.52
52
53| investing
54+ 1240 first deposit
55+ 2.40 second deposit
56+ 4.13 investing hard!
57= 1246.53
58
59| savings account 2
60+ 1000 first
61- 40 don't know
62+ 55.55 more deposited
63= 1015.55
64
65| investing hard
66+ 12400000.45 lot of money!!
67= 12400000.45
68`;
69
70 const response = moneyBlockProcess(data);
71
72 t.is(response, expected);
73});
74
75test('four groups with total', function(t) {
76 const data = readMock('four-groups-with-total.txt');
77 const expected = `$ 12402867.05
78
79| savings account
80+ 123 first deposit
81+ 111 second deposit
82- 29.48 wasting money
83+ 400 saved a lot!!!
84= 604.52
85
86| investing
87+ 1240 first deposit
88+ 2.40 second deposit
89+ 4.13 investing hard!
90= 1246.53
91
92| savings account 2
93+ 1000 first
94- 40 don't know
95+ 55.55 more deposited
96= 1015.55
97
98| investing hard
99+ 12400000.45 lot of money!!
100= 12400000.45
101`;
102
103 const response = moneyBlockProcess(data);
104
105 t.is(response, expected);
106});
107
108test('four groups with balance', function(t) {
109 const data = readMock('four-groups-with-balance.txt');
110 const expected = `$ 12402867.05
111
112| savings account
113+ 123 first deposit
114+ 111 second deposit
115- 29.48 wasting money
116+ 400 saved a lot!!!
117= 604.52
118
119| investing
120+ 1240 first deposit
121+ 2.40 second deposit
122+ 4.13 investing hard!
123= 1246.53
124
125| savings account 2
126+ 1000 first
127- 40 don't know
128+ 55.55 more deposited
129= 1015.55
130
131| investing hard
132+ 12400000.45 lot of money!!
133= 12400000.45
134`;
135
136 const response = moneyBlockProcess(data);
137
138 t.is(response, expected);
139});
140
141test('four groups with balance ignoring last group', function(t) {
142 const data = readMock('four-groups-with-balance-ignore-group.txt');
143 const expected = `$ 2866.60
144
145| savings account
146+ 123 first deposit
147+ 111 second deposit
148- 29.48 wasting money
149+ 400 saved a lot!!!
150= 604.52
151
152| investing
153+ 1240 first deposit
154+ 2.40 second deposit
155+ 4.13 investing hard!
156= 1246.53
157
158| savings account 2
159+ 1000 first
160- 40 don't know
161+ 55.55 more deposited
162= 1015.55
163
164|- investing hard
165+ 12400000.45 lot of money!!
166= 12400000.45
167`;
168
169 const response = moneyBlockProcess(data);
170
171 t.is(response, expected);
172});
173

Built with git-ssb-web