add money tracker
All checks were successful
Test and deploy staging / staging (push) Successful in 1m46s
All checks were successful
Test and deploy staging / staging (push) Successful in 1m46s
This commit is contained in:
20
src/lib/server/money-tracker.test.ts
Normal file
20
src/lib/server/money-tracker.test.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { cents, csvDate, parseCsv } from './money-tracker';
|
||||
|
||||
describe('transaction import parsing', () => {
|
||||
it('handles quoted commas and semicolon-separated European amounts', () => {
|
||||
expect(
|
||||
parseCsv('date;account;description;amount\n23/09/2026;Cash;"Food; drinks";-12,50')[1]
|
||||
).toEqual(['23/09/2026', 'Cash', 'Food; drinks', '-12,50']);
|
||||
expect(
|
||||
parseCsv('date,account,description,amount\n2026-09-23,Cash,"Food, drinks",-12.50')[1][2]
|
||||
).toBe('Food, drinks');
|
||||
expect(csvDate('23/09/2026')).toBe('2026-09-23');
|
||||
expect(cents('-12,50')).toBe(-1250);
|
||||
});
|
||||
|
||||
it('rejects invalid dates and amounts rather than altering them', () => {
|
||||
expect(csvDate('31/02/2026')).toBeNull();
|
||||
expect(cents('1.234,56')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user