feat: add team cash flow amount presentation
This commit is contained in:
@@ -1,4 +1,50 @@
|
||||
import { signedTransactionAmount } from './transaction-amount';
|
||||
import { presentCashFlow, signedTransactionAmount } from './transaction-amount';
|
||||
|
||||
describe('presentCashFlow', () => {
|
||||
it.each([
|
||||
{
|
||||
amount: 12,
|
||||
type: 0,
|
||||
context: 'player' as const,
|
||||
expected: { direction: 'inflow', amount: 12, sign: '+' },
|
||||
},
|
||||
{
|
||||
amount: -12,
|
||||
type: 'payment',
|
||||
context: 'player' as const,
|
||||
expected: { direction: 'outflow', amount: 12, sign: '−' },
|
||||
},
|
||||
{
|
||||
amount: 8.5,
|
||||
type: { id: 1, name: 'credit' },
|
||||
context: 'team' as const,
|
||||
expected: { direction: 'inflow', amount: 8.5, sign: '+' },
|
||||
},
|
||||
{
|
||||
amount: 8.5,
|
||||
type: { id: 14, name: 'expense' },
|
||||
context: 'team' as const,
|
||||
expected: { direction: 'outflow', amount: 8.5, sign: '−' },
|
||||
},
|
||||
{
|
||||
amount: 7,
|
||||
type: 'fine',
|
||||
context: 'player' as const,
|
||||
expected: { direction: 'neutral', amount: 7, sign: '' },
|
||||
},
|
||||
{
|
||||
amount: -7,
|
||||
type: 'unknown',
|
||||
context: 'player' as const,
|
||||
expected: { direction: 'neutral', amount: 7, sign: '' },
|
||||
},
|
||||
])(
|
||||
'presents $context $type transactions with their cash-flow direction',
|
||||
({ amount, type, context, expected }) => {
|
||||
expect(presentCashFlow(amount, type, context)).toEqual(expected);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('signedTransactionAmount', () => {
|
||||
it('shows debit transaction types as negative amounts', () => {
|
||||
|
||||
Reference in New Issue
Block a user