🐛 add env to useDb and apply prettier
tinyedge/deploy Deployed by TinyEdge

This commit is contained in:
2026-08-07 13:28:26 +02:00
parent 67727f96ab
commit cbe1b42f6e
54 changed files with 5492 additions and 2406 deletions
+17 -17
View File
@@ -1,30 +1,30 @@
import { describe, expect, it } from 'vitest'
import { computeSplit } from './split'
import { describe, expect, it } from 'vitest';
import { computeSplit } from './split';
describe('computeSplit', () => {
it('divides evenly when amount divides cleanly', () => {
expect(computeSplit(1000, [1, 2, 4])).toEqual({ 1: 334, 2: 333, 4: 333 })
})
expect(computeSplit(1000, [1, 2, 4])).toEqual({ 1: 334, 2: 333, 4: 333 });
});
it('sums back exactly to the original amount', () => {
const shares = computeSplit(1001, [1, 2, 3, 4, 5, 6, 7])
const total = Object.values(shares).reduce((sum, share) => sum + share, 0)
expect(total).toBe(1001)
})
const shares = computeSplit(1001, [1, 2, 3, 4, 5, 6, 7]);
const total = Object.values(shares).reduce((sum, share) => sum + share, 0);
expect(total).toBe(1001);
});
it('distributes remainder cents one-each to the first participants in order', () => {
expect(computeSplit(10, [1, 2, 3])).toEqual({ 1: 4, 2: 3, 3: 3 })
})
expect(computeSplit(10, [1, 2, 3])).toEqual({ 1: 4, 2: 3, 3: 3 });
});
it('gives the full amount to a single participant', () => {
expect(computeSplit(1234, [9])).toEqual({ 9: 1234 })
})
expect(computeSplit(1234, [9])).toEqual({ 9: 1234 });
});
it('handles a zero amount', () => {
expect(computeSplit(0, [1, 2])).toEqual({ 1: 0, 2: 0 })
})
expect(computeSplit(0, [1, 2])).toEqual({ 1: 0, 2: 0 });
});
it('throws when given no participants', () => {
expect(() => computeSplit(1000, [])).toThrow()
})
})
expect(() => computeSplit(1000, [])).toThrow();
});
});