const test = require('ava'); const { readMock } = require('./helpers/mock'); const moneyBlockProcess = require('../src/index'); test('single group', function(t) { const data = readMock('single-group.txt'); const expected = `$ 234 | savings account + 123 first deposit + 111 second deposit = 234 `; const response = moneyBlockProcess(data); t.is(response, expected); }); test('two groups', function(t) { const data = readMock('two-groups.txt'); const expected = `$ 1480.53 | savings account + 123 first deposit + 111 second deposit = 234 | investing + 1240 first deposit + 2.40 second deposit + 4.13 investing hard! = 1246.53 `; const response = moneyBlockProcess(data); t.is(response, expected); }); test('four groups', function(t) { const data = readMock('four-groups.txt'); const expected = `$ 12402867.05 | savings account + 123 first deposit + 111 second deposit - 29.48 wasting money + 400 saved a lot!!! = 604.52 | investing + 1240 first deposit + 2.40 second deposit + 4.13 investing hard! = 1246.53 | savings account 2 + 1000 first - 40 don't know + 55.55 more deposited = 1015.55 | investing hard + 12400000.45 lot of money!! = 12400000.45 `; const response = moneyBlockProcess(data); t.is(response, expected); }); test('four groups with total', function(t) { const data = readMock('four-groups-with-total.txt'); const expected = `$ 12402867.05 | savings account + 123 first deposit + 111 second deposit - 29.48 wasting money + 400 saved a lot!!! = 604.52 | investing + 1240 first deposit + 2.40 second deposit + 4.13 investing hard! = 1246.53 | savings account 2 + 1000 first - 40 don't know + 55.55 more deposited = 1015.55 | investing hard + 12400000.45 lot of money!! = 12400000.45 `; const response = moneyBlockProcess(data); t.is(response, expected); }); test('four groups with balance', function(t) { const data = readMock('four-groups-with-balance.txt'); const expected = `$ 12402867.05 | savings account + 123 first deposit + 111 second deposit - 29.48 wasting money + 400 saved a lot!!! = 604.52 | investing + 1240 first deposit + 2.40 second deposit + 4.13 investing hard! = 1246.53 | savings account 2 + 1000 first - 40 don't know + 55.55 more deposited = 1015.55 | investing hard + 12400000.45 lot of money!! = 12400000.45 `; const response = moneyBlockProcess(data); t.is(response, expected); }); test('four groups with balance ignoring last group', function(t) { const data = readMock('four-groups-with-balance-ignore-group.txt'); const expected = `$ 2866.60 | savings account + 123 first deposit + 111 second deposit - 29.48 wasting money + 400 saved a lot!!! = 604.52 | investing + 1240 first deposit + 2.40 second deposit + 4.13 investing hard! = 1246.53 | savings account 2 + 1000 first - 40 don't know + 55.55 more deposited = 1015.55 |- investing hard + 12400000.45 lot of money!! = 12400000.45 `; const response = moneyBlockProcess(data); t.is(response, expected); });