forked from onivim/oni2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LanguageCssTest.re
101 lines (87 loc) · 2.4 KB
/
LanguageCssTest.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
open Oni_Core;
open Oni_Model;
open Oni_IntegrationTestLib;
// This test validates:
// - The 'oni-dev' extension gets activated
// - When typing in an 'oni-dev' buffer, we get some completion results
runTest(~name="LanguageCssTest", ({input, dispatch, wait, _}) => {
wait(~name="Capture initial state", (state: State.t) =>
Selectors.mode(state) |> Vim.Mode.isNormal
);
ExtensionHelpers.waitForExtensionToActivate(
~extensionId="oni-dev-extension",
wait,
);
ExtensionHelpers.waitForNewCompletionProviders(
~description="css completion",
() => {
// Create a buffer
dispatch(
Actions.OpenFileByPath("test.css", SplitDirection.Current, None),
);
// Wait for the CSS filetype
wait(
~timeout=30.0,
~name="Validate we have a CSS filetype",
(state: State.t) => {
let fileType =
Selectors.getActiveBuffer(state)
|> Option.map(Buffer.getFileType)
|> Option.map(Buffer.FileType.toString);
fileType == Some("css");
},
);
ExtensionHelpers.waitForExtensionToActivate(
~extensionId="vscode.css-language-features",
wait,
);
},
wait,
);
// Enter some text
input("i");
input("a");
// Should get an error diagnostic
wait(
~timeout=30.0,
~name=
"Validate a diagnostic showed up, since our current input is erroneous",
(state: State.t) => {
let bufferOpt = Selectors.getActiveBuffer(state);
switch (bufferOpt) {
| Some(buffer) =>
let diags =
Feature_Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) > 0;
| _ => false
};
},
);
// Should've also gotten some completions...
wait(
~timeout=30.0,
~name="Validate we also got some completions",
(state: State.t) =>
state.languageSupport
|> Feature_LanguageSupport.Completion.availableCompletionCount > 0
);
// Finish input, clear diagnostics
input(" ");
input("{");
input("color:red");
input("}");
wait(
~timeout=30.0,
~name="Validate no diagnostics now",
(state: State.t) => {
let bufferOpt = Selectors.getActiveBuffer(state);
switch (bufferOpt) {
| Some(buffer) =>
let diags =
Feature_Diagnostics.getDiagnostics(state.diagnostics, buffer);
List.length(diags) == 0;
| _ => false
};
},
);
});