forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClipboardYankTest.re
116 lines (98 loc) · 3.31 KB
/
ClipboardYankTest.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;
let optEqual = (sOpt, s) => {
switch (sOpt) {
| None => false
| Some(v) => String.equal(v, s)
};
};
let printOpt = sOpt =>
switch (sOpt) {
| None => "[None]"
| Some(v) => "Some(" ++ v ++ ")"
};
runTest(~name="ClipboardYankTest", ({dispatch, wait, runEffects, _}) => {
wait(~name="Set configuration to always yank to clipboard", _ => {
let transformer =
ConfigurationTransformer.setField(
"vim.useSystemClipboard",
`List([`String("yank")]),
);
dispatch(
Configuration(Feature_Configuration.Testing.transform(transformer)),
);
runEffects();
true;
});
wait(~name="Wait for configuration to update", (state: State.t) => {
Feature_Vim.useSystemClipboard(state.vim)
== Feature_Vim.{yank: true, delete: false, paste: false}
});
dispatch(KeyboardInput({isText: true, input: "i"}));
wait(~name="Mode switches to insert", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isInsert
);
dispatch(KeyboardInput({isText: true, input: "abc"}));
dispatch(KeyboardInput({isText: false, input: "<esc>"}));
runEffects();
wait(~name="Mode switches back to normal", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);
setClipboard(None);
/* Validate yank w/ no register sets clipboard */
dispatch(KeyboardInput({isText: true, input: "yy"}));
runEffects();
wait(~name="Yank 1 is sent to clipboard", _ => {
print_endline("CLIPBOARD: " ++ printOpt(getClipboard()));
optEqual(getClipboard(), "abc\n");
});
setClipboard(None);
/* Validate yank w/ a register sets clipboard */
dispatch(KeyboardInput({isText: true, input: "\"ayy"}));
runEffects();
wait(~name="Yank 2 is sent to clipboard", _ => {
print_endline("CLIPBOARD: " ++ printOpt(getClipboard()));
optEqual(getClipboard(), "abc\n");
});
wait(~name="Set configuration to not yank clipboard by default", _ => {
let transformer =
ConfigurationTransformer.setField(
"vim.useSystemClipboard",
`Bool(false),
);
dispatch(
Configuration(Feature_Configuration.Testing.transform(transformer)),
);
runEffects();
true;
});
wait(~name="Wait for configuration to update", (state: State.t) => {
Feature_Vim.useSystemClipboard(state.vim)
== Feature_Vim.{yank: false, delete: false, paste: false}
});
setClipboard(None);
/* Validate yank w/ no register doesn't set clipboard */
dispatch(KeyboardInput({isText: true, input: "yy"}));
runEffects();
wait(~name="Yank 3 is NOT sent to clipboard", _ => {
print_endline("CLIPBOARD: " ++ printOpt(getClipboard()));
getClipboard() == None;
});
setClipboard(None);
/* Validate yank w/ a register doesn't set clipboard */
dispatch(KeyboardInput({isText: true, input: "\"ayy"}));
runEffects();
wait(~name="Yank 4 w/ register 'a' is NOT sent to clipboard", _ => {
print_endline("CLIPBOARD: " ++ printOpt(getClipboard()));
getClipboard() == None;
});
setClipboard(None);
/* Validate yank w/ + register sets clipboard */
dispatch(KeyboardInput({isText: true, input: "\"+yy"}));
runEffects();
wait(~name="Yank 4 w/ register '+' is still sent to clipboard", _ => {
print_endline("CLIPBOARD: " ++ printOpt(getClipboard()));
optEqual(getClipboard(), "abc\n");
});
});