Initial build: SimpleScan Solo v0.1.0 - Freelancer receipt capture Chrome extension
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { describe, it } from 'node:test';
|
||||
import assert from 'node:assert';
|
||||
// Test categories
|
||||
import { TAX_CATEGORIES, getCategoryLabel, getCategoryIcon } from '../utils/categories.js';
|
||||
describe('categories', () => {
|
||||
it('has 10 tax categories', () => {
|
||||
assert.strictEqual(TAX_CATEGORIES.length, 10);
|
||||
});
|
||||
it('gets correct label', () => {
|
||||
assert.strictEqual(getCategoryLabel('software'), 'Software');
|
||||
assert.strictEqual(getCategoryLabel('equipment'), 'Equipment');
|
||||
assert.strictEqual(getCategoryLabel('nonexistent'), 'Other');
|
||||
});
|
||||
it('gets correct icon', () => {
|
||||
assert.strictEqual(getCategoryIcon('software'), '⚙️');
|
||||
assert.strictEqual(getCategoryIcon('travel'), '✈️');
|
||||
assert.strictEqual(getCategoryIcon('nonexistent'), '📦');
|
||||
});
|
||||
});
|
||||
// Test export
|
||||
import { exportToCsv } from '../utils/export.js';
|
||||
describe('export', () => {
|
||||
it('exports receipts to CSV', () => {
|
||||
const receipts = [
|
||||
{
|
||||
id: '1',
|
||||
title: 'Adobe CC',
|
||||
amount: 59.99,
|
||||
currency: 'USD',
|
||||
category: 'software',
|
||||
date: '2026-06-01',
|
||||
vendor: 'Adobe',
|
||||
notes: 'Monthly',
|
||||
source: 'manual',
|
||||
createdAt: '2026-06-01T00:00:00Z',
|
||||
},
|
||||
];
|
||||
const csv = exportToCsv(receipts);
|
||||
console.log('CSV output:', csv);
|
||||
assert.ok(csv.includes('Date'), 'CSV should have Date header');
|
||||
assert.ok(csv.includes('Adobe CC'), 'CSV should have title');
|
||||
assert.ok(csv.includes('59.99'), 'CSV should have amount');
|
||||
assert.ok(csv.includes('Software'), 'CSV should have category label');
|
||||
});
|
||||
it('escapes quotes in CSV', () => {
|
||||
const receipts = [
|
||||
{
|
||||
id: '1',
|
||||
title: 'My "Special" Item',
|
||||
amount: 10,
|
||||
currency: 'USD',
|
||||
category: 'other',
|
||||
date: '2026-06-01',
|
||||
vendor: 'Vendor',
|
||||
notes: '',
|
||||
source: 'manual',
|
||||
createdAt: '2026-06-01T00:00:00Z',
|
||||
},
|
||||
];
|
||||
const csv = exportToCsv(receipts);
|
||||
assert.ok(csv.includes('""'), 'CSV should escape quotes');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user