mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
16 lines
628 B
TypeScript
16 lines
628 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { normalizedTransactionAmountSql } from '../src/transaction-amount';
|
|
|
|
describe('normalizedTransactionAmountSql', () => {
|
|
it('builds normalized expressions with and without a table alias', () => {
|
|
expect(normalizedTransactionAmountSql()).toBe('COALESCE(amount_local, amount)');
|
|
expect(normalizedTransactionAmountSql('t')).toBe('COALESCE(t.amount_local, t.amount)');
|
|
});
|
|
|
|
it('rejects non-identifier aliases', () => {
|
|
expect(() => normalizedTransactionAmountSql('t; DROP TABLE transactions')).toThrow(
|
|
'Invalid transaction table alias'
|
|
);
|
|
});
|
|
});
|