Skip to content

Commit 57b3398

Browse files
jonmbakeCopilot
andauthored
Move tests to "Terminal history persistence block
Co-authored-by: Copilot <[email protected]>
1 parent 3720063 commit 57b3398

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

tests/terminal.history.spec.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,32 @@ describe("Terminal history persistence", () => {
102102

103103
expect(input).toHaveValue("first");
104104
});
105-
});
106105

107-
test("preserves current input when navigating history and returning back down", () => {
108-
localStorage.setItem("terminal-history", JSON.stringify(["old1", "old2"]));
106+
test("preserves current input when navigating history and returning back down", () => {
107+
localStorage.setItem("terminal-history", JSON.stringify(["old1", "old2"]));
109108

110-
render(<Terminal onInput={() => { }} />);
111-
const input = screen.getByPlaceholderText("Terminal Hidden Input");
109+
render(<Terminal onInput={() => { }} />);
110+
const input = screen.getByPlaceholderText("Terminal Hidden Input");
112111

113-
fireEvent.change(input, { target: { value: "new-typing" } });
112+
fireEvent.change(input, { target: { value: "new-typing" } });
114113

115-
fireEvent.keyDown(input, { key: "ArrowUp" });
116-
expect(input).toHaveValue("old2");
114+
fireEvent.keyDown(input, { key: "ArrowUp" });
115+
expect(input).toHaveValue("old2");
117116

118-
fireEvent.keyDown(input, { key: "ArrowDown" });
119-
expect(input).toHaveValue("new-typing");
120-
});
117+
fireEvent.keyDown(input, { key: "ArrowDown" });
118+
expect(input).toHaveValue("new-typing");
119+
});
121120

122-
test("does not clear input when ArrowDown is pressed while at latest history entry", () => {
123-
localStorage.setItem("terminal-history", JSON.stringify(["cmdA", "cmdB"]));
121+
test("does not clear input when ArrowDown is pressed while at latest history entry", () => {
122+
localStorage.setItem("terminal-history", JSON.stringify(["cmdA", "cmdB"]));
124123

125-
render(<Terminal onInput={() => { }} />);
126-
const input = screen.getByPlaceholderText("Terminal Hidden Input");
124+
render(<Terminal onInput={() => { }} />);
125+
const input = screen.getByPlaceholderText("Terminal Hidden Input");
127126

128-
fireEvent.keyDown(input, { key: "ArrowUp" });
129-
expect(input).toHaveValue("cmdB");
127+
fireEvent.keyDown(input, { key: "ArrowUp" });
128+
expect(input).toHaveValue("cmdB");
130129

131-
fireEvent.keyDown(input, { key: "ArrowDown" });
132-
expect(input).toHaveValue("");
130+
fireEvent.keyDown(input, { key: "ArrowDown" });
131+
expect(input).toHaveValue("");
132+
});
133133
});

0 commit comments

Comments
 (0)