Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/unit/StringUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,26 @@ second
expect(StringUtils.sanitizeName(` Custom rate `)).toBe('Custom rate');
});
});

describe('getFirstLine', () => {
it('returns only the text before the first newline', () => {
// Given a merchant name stored with line breaks, which a transaction row has room for only one line of
const text = 'First line\nSecond line\nThird line';

// When the merchant column resolves the name through getMerchantName
const result = StringUtils.getFirstLine(text);

// Then only the first line reaches the row, so the cell keeps a single-line height
expect(result).toBe('First line');
});

it('returns an empty string when there is no text', () => {
Comment thread
BartekObudzinski marked this conversation as resolved.
Resolved
// Given a transaction with no merchant, which must still render an empty cell
// When the merchant column resolves the name
const result = StringUtils.getFirstLine();

// Then callers get an empty string instead of undefined, so they can render it without a guard
expect(result).toBe('');
});
});
});
Loading