From 89a29763f7994c6e2183c080130039554908b5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Obudzi=C5=84ski?= Date: Mon, 19 Oct 2026 15:26:52 +0200 Subject: [PATCH] test: cover StringUtils.getFirstLine --- tests/unit/StringUtilsTest.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/unit/StringUtilsTest.ts b/tests/unit/StringUtilsTest.ts index ec8b9ef1c5e5..5b01acb139e3 100644 --- a/tests/unit/StringUtilsTest.ts +++ b/tests/unit/StringUtilsTest.ts @@ -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', () => { + // 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(''); + }); + }); });