Skip to content

Commit d67239d

Browse files
committed
test(web): cover mobile line-copy null cases
1 parent f59d53d commit d67239d

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

packages/web/src/features/terminal-panel/mobile/long-press-copy-line.test.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function createRowsDom() {
5757

5858
return {
5959
rows,
60-
firstTarget: firstRow.querySelector("span") as HTMLSpanElement,
6160
secondTarget: secondRow.querySelector("span span") as HTMLSpanElement,
6261
thirdTarget: thirdRow.querySelector("span span") as HTMLSpanElement,
6362
};
@@ -109,6 +108,28 @@ describe("getLogicalLineTextFromTouchTarget", () => {
109108
rows.remove();
110109
});
111110

111+
it("returns null when the mapped buffer row is missing", () => {
112+
const { rows, secondTarget } = createRowsDom();
113+
document.body.appendChild(rows);
114+
115+
const terminal = createTerminal(40, [[40, createBufferLine("alpha")]]);
116+
117+
expect(getLogicalLineTextFromTouchTarget({ target: secondTarget, terminal })).toBeNull();
118+
119+
rows.remove();
120+
});
121+
122+
it("returns null when a wrapped row's preceding segment is missing", () => {
123+
const { rows, secondTarget } = createRowsDom();
124+
document.body.appendChild(rows);
125+
126+
const terminal = createTerminal(50, [[51, createBufferLine("suffix ", true)]]);
127+
128+
expect(getLogicalLineTextFromTouchTarget({ target: secondTarget, terminal })).toBeNull();
129+
130+
rows.remove();
131+
});
132+
112133
it("returns null when the touch target does not resolve to a direct xterm row", () => {
113134
const outside = document.createElement("div");
114135
outside.innerHTML = "<span>outside</span>";

0 commit comments

Comments
 (0)