forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVimSimpleRemapTest.re
59 lines (47 loc) · 1.51 KB
/
VimSimpleRemapTest.re
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
open Oni_Model;
open Oni_IntegrationTestLib;
runTest(~name="VimSimpleRemapTest", ({dispatch, wait, runEffects, input, _}) => {
wait(~name="Initial mode is normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);
// Use inoremap to set up jj -> <ESC> binding
dispatch(
VimExecuteCommand({allowAnimation: true, command: "inoremap jj <ESC>"}),
);
runEffects();
input("i");
wait(~name="Mode is now insert", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isInsert
);
input("a");
input("j");
input("j");
wait(~name="Mode is back to normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);
wait(~name="Validate buffer is empty", (state: State.t) => {
let actual =
Model.Selectors.getActiveBuffer(state)
|> Option.map(Core.Buffer.getLines)
|> Option.map(Array.to_list);
actual == Some(["a"]);
});
wait(~name="#2601: Validate editor mode is normal, too", (state: State.t) => {
let editorMode =
state.layout |> Feature_Layout.activeEditor |> Feature_Editor.Editor.mode;
Vim.Mode.isNormal(editorMode);
});
// #2601 - Make sure we're _actually_ in normal mode!
// Type another 'j' to see...
input("j");
wait(
~name=
"#2601: Buffer should _still_ be empty, since we used j in normal mode",
(state: State.t) => {
let actual =
Model.Selectors.getActiveBuffer(state)
|> Option.map(Core.Buffer.getLines)
|> Option.map(Array.to_list);
actual == Some(["a"]);
});
});