forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditorUtf8Test.re
61 lines (49 loc) · 1.98 KB
/
EditorUtf8Test.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
60
61
open EditorCoreTypes;
open Oni_Core;
open Oni_Core.Utility;
open Oni_Model;
open Oni_IntegrationTestLib;
open Feature_Editor;
runTest(~name="EditorUtf8Test", ({input, dispatch, wait, _}) => {
wait(~name="Initial mode is normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);
let testFile = getAssetPath("utf8.txt");
dispatch(Actions.OpenFileByPath(testFile, SplitDirection.Current, None));
wait(~name="Verify buffer is loaded", (state: State.t) => {
state
|> Selectors.getActiveBuffer
|> OptionEx.flatMap(Buffer.getShortFriendlyName)
|> Option.map(name => String.equal(name, "utf8.txt"))
|> Option.value(~default=false)
});
let str = "κόσμε" |> Oni_Core.BufferLine.make(~measure=_ => 1.0);
let c0 = BufferLine.getUcharExn(~index=CharacterIndex.ofInt(0), str);
let c1 = BufferLine.getUcharExn(~index=CharacterIndex.ofInt(1), str);
let c2 = BufferLine.getUcharExn(~index=CharacterIndex.ofInt(2), str);
let c3 = BufferLine.getUcharExn(~index=CharacterIndex.ofInt(3), str);
let c4 = BufferLine.getUcharExn(~index=CharacterIndex.ofInt(4), str);
let validateCharacter = (expectedCharacter, state: State.t) => {
state.layout
|> Feature_Layout.activeEditor
|> Editor.getCharacterUnderCursor
|> Option.map(uchar => {Uchar.equal(expectedCharacter, uchar)})
|> Option.value(~default=false);
};
wait(~name="Verify first character", validateCharacter(c0));
input("l");
wait(~name="Verify second character", validateCharacter(c1));
input("l");
wait(~name="Verify third character", validateCharacter(c2));
input("l");
wait(~name="Verify fourth character", validateCharacter(c3));
input("l");
wait(~name="Verify fifth character", validateCharacter(c4));
// TODO: Insert mode validation, too?
/*dispatch(KeyboardInput("A"));
wait(~name="Mode switches to insert", (state: State.t) =>
state.vimMode == Vim.Types.Insert
);
wait(~name="Verify fifth character", validateCharacter(c4));
*/
});