|
6 | 6 | formatCellValueForCopy, |
7 | 7 | formatColumnType, |
8 | 8 | isLeftAligned, |
| 9 | + toSingleLineDisplay, |
9 | 10 | } from "./inlineGridUtils" |
10 | 11 | import type { ColumnDefinition } from "../../utils/questdb/types" |
11 | 12 |
|
@@ -193,6 +194,34 @@ describe("formatCellValueForCopy", () => { |
193 | 194 | // Then the copied text is preserved exactly as returned by the server |
194 | 195 | expect(out).toBe("a&b<c>d") |
195 | 196 | }) |
| 197 | + |
| 198 | + it("preserves embedded line breaks so copy keeps the raw value", () => { |
| 199 | + const out = formatCellValueForCopy( |
| 200 | + "line1\nline2\r\nline3", |
| 201 | + col("x", "VARCHAR"), |
| 202 | + ) |
| 203 | + |
| 204 | + expect(out).toBe("line1\nline2\r\nline3") |
| 205 | + }) |
| 206 | +}) |
| 207 | + |
| 208 | +describe("toSingleLineDisplay", () => { |
| 209 | + it("collapses line breaks to a single space so cells render on one line", () => { |
| 210 | + expect(toSingleLineDisplay("line1\nline2")).toBe("line1 line2") |
| 211 | + expect(toSingleLineDisplay("line1\r\nline2")).toBe("line1 line2") |
| 212 | + expect(toSingleLineDisplay("line1\rline2")).toBe("line1 line2") |
| 213 | + expect(toSingleLineDisplay("a\n\n\nb")).toBe("a b") |
| 214 | + }) |
| 215 | + |
| 216 | + it("preserves leading and interior spaces (rendered via white-space: pre)", () => { |
| 217 | + expect(toSingleLineDisplay(" indented")).toBe(" indented") |
| 218 | + expect(toSingleLineDisplay("a b")).toBe("a b") |
| 219 | + }) |
| 220 | + |
| 221 | + it("leaves values without line breaks untouched", () => { |
| 222 | + expect(toSingleLineDisplay("a&b<c>d")).toBe("a&b<c>d") |
| 223 | + expect(toSingleLineDisplay("")).toBe("") |
| 224 | + }) |
196 | 225 | }) |
197 | 226 |
|
198 | 227 | describe("sampleColumnWidths", () => { |
|
0 commit comments