Skip to content

Commit

Permalink
Add tests for some command line special keys
Browse files Browse the repository at this point in the history
Includes <C-b>, <C-e>, <C-u>, <Home>, and <End>.
Still to-do: <C-p> and <C-n>
Fixes #4040
  • Loading branch information
J-Fields committed Sep 22, 2019
1 parent 885d6e9 commit d6838e0
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/cmd_line/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,46 @@ suite('cmd_line/search command', () => {
assert.equal(statusBar, '/|123', 'Failed to retain the text on the right of the cursor');
await modeHandler.handleKeyEvent('<Esc>');
});

// TODO: <C-p> and <C-n> tests

test('<C-u> deletes from cursor to first character', async () => {
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
await modeHandler.handleMultipleKeyEvents(['<left>', '<left>', '<C-u>']);
const statusBar = StatusBar.Get().trim();
assert.equal(statusBar, ':|yz');
await modeHandler.handleKeyEvent('<Esc>');
});

test('<C-b> puts cursor at start of command line', async () => {
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
await modeHandler.handleKeyEvent('<C-b>');
const statusBar = StatusBar.Get().trim();
assert.equal(statusBar, ':|s/abc/xyz');
await modeHandler.handleKeyEvent('<Esc>');
});

test('<Home> puts cursor at start of command line', async () => {
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
await modeHandler.handleKeyEvent('<Home>');
const statusBar = StatusBar.Get().trim();
assert.equal(statusBar, ':|s/abc/xyz');
await modeHandler.handleKeyEvent('<Esc>');
});

test('<C-e> puts cursor at end of command line', async () => {
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
await modeHandler.handleMultipleKeyEvents(['<C-b>', '<C-e>']);
const statusBar = StatusBar.Get().trim();
assert.equal(statusBar, ':s/abc/xyz|');
await modeHandler.handleKeyEvent('<Esc>');
});

test('<End> puts cursor at end of command line', async () => {
await modeHandler.handleMultipleKeyEvents(':s/abc/xyz'.split(''));
await modeHandler.handleMultipleKeyEvents(['<Home>', '<End>']);
const statusBar = StatusBar.Get().trim();
assert.equal(statusBar, ':s/abc/xyz|');
await modeHandler.handleKeyEvent('<Esc>');
});
});

0 comments on commit d6838e0

Please sign in to comment.