@@ -79,16 +79,20 @@ describe("Editor component", () => {
|
||||
assert.strictEqual(editor.getText(), "first");
|
||||
});
|
||||
|
||||
it("returns to empty editor on Down arrow after browsing history", () => {
|
||||
it("restores draft on Down arrow after browsing history", () => {
|
||||
const editor = new Editor(createTestTUI(), defaultEditorTheme);
|
||||
|
||||
editor.addToHistory("prompt");
|
||||
editor.setText("draft");
|
||||
editor.handleInput("\x1b[D");
|
||||
editor.handleInput("\x1b[D");
|
||||
|
||||
editor.handleInput("\x1b[A"); // Up - shows "prompt"
|
||||
assert.strictEqual(editor.getText(), "prompt");
|
||||
|
||||
editor.handleInput("\x1b[B"); // Down - clears editor
|
||||
assert.strictEqual(editor.getText(), "");
|
||||
editor.handleInput("\x1b[B"); // Down - restores draft
|
||||
assert.strictEqual(editor.getText(), "draft");
|
||||
assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
|
||||
});
|
||||
|
||||
it("navigates forward through history with Down arrow", () => {
|
||||
@@ -97,6 +101,7 @@ describe("Editor component", () => {
|
||||
editor.addToHistory("first");
|
||||
editor.addToHistory("second");
|
||||
editor.addToHistory("third");
|
||||
editor.setText("draft");
|
||||
|
||||
// Go to oldest
|
||||
editor.handleInput("\x1b[A"); // third
|
||||
@@ -110,8 +115,8 @@ describe("Editor component", () => {
|
||||
editor.handleInput("\x1b[B"); // third
|
||||
assert.strictEqual(editor.getText(), "third");
|
||||
|
||||
editor.handleInput("\x1b[B"); // empty
|
||||
assert.strictEqual(editor.getText(), "");
|
||||
editor.handleInput("\x1b[B"); // draft
|
||||
assert.strictEqual(editor.getText(), "draft");
|
||||
});
|
||||
|
||||
it("exits history mode when typing a character", () => {
|
||||
|
||||
Reference in New Issue
Block a user