Skip to content

Commit bea06de

Browse files
authored
test: add highlight test & screenshot tests (#14)
1 parent be50459 commit bea06de

6 files changed

+201
-0
lines changed

tests/fixtures/highlight_test.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
3+
int main(void) {
4+
const char *name = "World";
5+
printf("Hello, %s!\n", name);
6+
return 0;
7+
}

tests/mock_lsp.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ local function getNesResponse(td)
6868
},
6969
},
7070
},
71+
["highlight_test.c"] = {
72+
edits = {
73+
{
74+
command = { title = "mock", command = "mock" },
75+
range = {
76+
start = { line = 4, character = 0 },
77+
["end"] = { line = 4, character = 30 },
78+
},
79+
textDocument = td,
80+
text = [[ printf("Goodb, %s!\n", name);]],
81+
---@diagnostic disable-next-line: assign-type-mismatch
82+
newText = nil,
83+
},
84+
},
85+
},
7186
}
7287
local response = responses[filename]
7388
assert(response, "unhandled doc")

tests/nes/test_nes.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,30 @@ T["nes"]["add only edit"] = function()
9898
end)
9999
ref(child.get_screenshot())
100100
end
101+
102+
T["nes"]["highlights replacement"] = function()
103+
child.cmd("edit tests/fixtures/highlight_test.c")
104+
child.lua_func(function()
105+
vim.cmd([[colorscheme vim]])
106+
vim.treesitter.start(0)
107+
vim.cmd([[hi! NesAdd guifg=NONE guibg=NONE]])
108+
vim.cmd([[hi! NesDelete guifg=NONE guibg=NONE]])
109+
end)
110+
ref(child.get_screenshot())
111+
vim.uv.sleep(500)
112+
local lsp_name = child.lua_func(function()
113+
return vim.lsp.get_clients()[1].name
114+
end)
115+
eq(lsp_name, "copilot")
116+
child.lua_func(function()
117+
local copilot = vim.lsp.get_clients()[1]
118+
require("copilot-lsp.nes").request_nes(copilot)
119+
end)
120+
vim.uv.sleep(500)
121+
ref(child.get_screenshot())
122+
child.lua_func(function()
123+
require("copilot-lsp.nes").apply_pending_nes(0)
124+
end)
125+
ref(child.get_screenshot())
126+
end
101127
return T
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--|---------|---------|---------|---------|---------|---------|---------|---------|
2+
01|#include <stdio.h>
3+
02|
4+
03|int main(void) {
5+
04| const char *name = "World";
6+
05| printf("Hello, %s!\n", name);
7+
06| return 0;
8+
07|}
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15|~
17+
16|~
18+
17|~
19+
18|~
20+
19|~
21+
20|~
22+
21|~
23+
22|~
24+
23|tests/fixtures/highlight_test.c 1,1 All
25+
24|
26+
27+
--|---------|---------|---------|---------|---------|---------|---------|---------|
28+
01|00000000122222222211111111111111111111111111111111111111111111111111111111111111
29+
02|11111111111111111111111111111111111111111111111111111111111111111111111111111111
30+
03|33314444333333131111111111111111111111111111111111111111111111111111111111111111
31+
04|11555551333315444415122222223111111111111111111111111111111111111111111111111111
32+
05|11444444322222222222332314444331111111111111111111111111111111111111111111111111
33+
06|11555555123111111111111111111111111111111111111111111111111111111111111111111111
34+
07|31111111111111111111111111111111111111111111111111111111111111111111111111111111
35+
08|66666666666666666666666666666666666666666666666666666666666666666666666666666666
36+
09|66666666666666666666666666666666666666666666666666666666666666666666666666666666
37+
10|66666666666666666666666666666666666666666666666666666666666666666666666666666666
38+
11|66666666666666666666666666666666666666666666666666666666666666666666666666666666
39+
12|66666666666666666666666666666666666666666666666666666666666666666666666666666666
40+
13|66666666666666666666666666666666666666666666666666666666666666666666666666666666
41+
14|66666666666666666666666666666666666666666666666666666666666666666666666666666666
42+
15|66666666666666666666666666666666666666666666666666666666666666666666666666666666
43+
16|66666666666666666666666666666666666666666666666666666666666666666666666666666666
44+
17|66666666666666666666666666666666666666666666666666666666666666666666666666666666
45+
18|66666666666666666666666666666666666666666666666666666666666666666666666666666666
46+
19|66666666666666666666666666666666666666666666666666666666666666666666666666666666
47+
20|66666666666666666666666666666666666666666666666666666666666666666666666666666666
48+
21|66666666666666666666666666666666666666666666666666666666666666666666666666666666
49+
22|66666666666666666666666666666666666666666666666666666666666666666666666666666666
50+
23|77777777777777777777777777777777777777777777777777777777777777777777777777777777
51+
24|11111111111111111111111111111111111111111111111111111111111111111111111111111111
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--|---------|---------|---------|---------|---------|---------|---------|---------|
2+
01|#include <stdio.h>
3+
02|
4+
03|int main(void) {
5+
04| const char *name = "World";
6+
05| printf("Hello, %s!\n", name);
7+
06| printf("Goodb, %s!\n", name);
8+
07| return 0;
9+
08|}
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15|~
17+
16|~
18+
17|~
19+
18|~
20+
19|~
21+
20|~
22+
21|~
23+
22|~
24+
23|tests/fixtures/highlight_test.c 1,1 All
25+
24|
26+
27+
--|---------|---------|---------|---------|---------|---------|---------|---------|
28+
01|00000000122222222211111111111111111111111111111111111111111111111111111111111111
29+
02|11111111111111111111111111111111111111111111111111111111111111111111111111111111
30+
03|33314444333333131111111111111111111111111111111111111111111111111111111111111111
31+
04|11555551333315444415122222223111111111111111111111111111111111111111111111111111
32+
05|11444444322222222222332314444331111111111111111111111111111111111111111111111111
33+
06|11444444322222222222222314444331111111111111111111111111111111111111111111111111
34+
07|11555555123111111111111111111111111111111111111111111111111111111111111111111111
35+
08|31111111111111111111111111111111111111111111111111111111111111111111111111111111
36+
09|66666666666666666666666666666666666666666666666666666666666666666666666666666666
37+
10|66666666666666666666666666666666666666666666666666666666666666666666666666666666
38+
11|66666666666666666666666666666666666666666666666666666666666666666666666666666666
39+
12|66666666666666666666666666666666666666666666666666666666666666666666666666666666
40+
13|66666666666666666666666666666666666666666666666666666666666666666666666666666666
41+
14|66666666666666666666666666666666666666666666666666666666666666666666666666666666
42+
15|66666666666666666666666666666666666666666666666666666666666666666666666666666666
43+
16|66666666666666666666666666666666666666666666666666666666666666666666666666666666
44+
17|66666666666666666666666666666666666666666666666666666666666666666666666666666666
45+
18|66666666666666666666666666666666666666666666666666666666666666666666666666666666
46+
19|66666666666666666666666666666666666666666666666666666666666666666666666666666666
47+
20|66666666666666666666666666666666666666666666666666666666666666666666666666666666
48+
21|66666666666666666666666666666666666666666666666666666666666666666666666666666666
49+
22|66666666666666666666666666666666666666666666666666666666666666666666666666666666
50+
23|77777777777777777777777777777777777777777777777777777777777777777777777777777777
51+
24|11111111111111111111111111111111111111111111111111111111111111111111111111111111
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
--|---------|---------|---------|---------|---------|---------|---------|---------|
2+
01|#include <stdio.h>
3+
02|
4+
03|int main(void) {
5+
04| const char *name = "World";
6+
05| printf("Goodb, %s!\n", name);;
7+
06| return 0;
8+
07|}
9+
08|~
10+
09|~
11+
10|~
12+
11|~
13+
12|~
14+
13|~
15+
14|~
16+
15|~
17+
16|~
18+
17|~
19+
18|~
20+
19|~
21+
20|~
22+
21|~
23+
22|~
24+
23|tests/fixtures/highlight_test.c [+] 5,32 All
25+
24|
26+
27+
--|---------|---------|---------|---------|---------|---------|---------|---------|
28+
01|00000000122222222211111111111111111111111111111111111111111111111111111111111111
29+
02|11111111111111111111111111111111111111111111111111111111111111111111111111111111
30+
03|33314444333333131111111111111111111111111111111111111111111111111111111111111111
31+
04|11555551333315444415122222223111111111111111111111111111111111111111111111111111
32+
05|11444444322222222222332314444333111111111111111111111111111111111111111111111111
33+
06|11555555123111111111111111111111111111111111111111111111111111111111111111111111
34+
07|31111111111111111111111111111111111111111111111111111111111111111111111111111111
35+
08|66666666666666666666666666666666666666666666666666666666666666666666666666666666
36+
09|66666666666666666666666666666666666666666666666666666666666666666666666666666666
37+
10|66666666666666666666666666666666666666666666666666666666666666666666666666666666
38+
11|66666666666666666666666666666666666666666666666666666666666666666666666666666666
39+
12|66666666666666666666666666666666666666666666666666666666666666666666666666666666
40+
13|66666666666666666666666666666666666666666666666666666666666666666666666666666666
41+
14|66666666666666666666666666666666666666666666666666666666666666666666666666666666
42+
15|66666666666666666666666666666666666666666666666666666666666666666666666666666666
43+
16|66666666666666666666666666666666666666666666666666666666666666666666666666666666
44+
17|66666666666666666666666666666666666666666666666666666666666666666666666666666666
45+
18|66666666666666666666666666666666666666666666666666666666666666666666666666666666
46+
19|66666666666666666666666666666666666666666666666666666666666666666666666666666666
47+
20|66666666666666666666666666666666666666666666666666666666666666666666666666666666
48+
21|66666666666666666666666666666666666666666666666666666666666666666666666666666666
49+
22|66666666666666666666666666666666666666666666666666666666666666666666666666666666
50+
23|77777777777777777777777777777777777777777777777777777777777777777777777777777777
51+
24|11111111111111111111111111111111111111111111111111111111111111111111111111111111

0 commit comments

Comments
 (0)