-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some preliminary tests, for checking error-reporting mostly.
Checking the happy path requires some more work, since the treesitter-parsers for lua and vscode need to be installed. Probably add those in makefile?
- Loading branch information
Showing
1 changed file
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
local helpers = require("test.functional.helpers")(after_each) | ||
local exec_lua, feed, exec = helpers.exec_lua, helpers.feed, helpers.exec | ||
local ls_helpers = require("helpers") | ||
local Screen = require("test.functional.ui.screen") | ||
local assert = require("luassert") | ||
|
||
describe("loaders:", function() | ||
local screen | ||
|
||
before_each(function() | ||
helpers.clear() | ||
|
||
screen = Screen.new(50, 8) | ||
screen:attach() | ||
screen:set_default_attr_ids({ | ||
[0] = { bold = true, foreground = Screen.colors.Blue }, | ||
[1] = { bold = true, foreground = Screen.colors.Brown }, | ||
[2] = { bold = true }, | ||
[3] = { background = Screen.colors.LightGray }, | ||
}) | ||
end) | ||
|
||
after_each(function() | ||
screen:detach() | ||
end) | ||
|
||
it("error-message when source not available", function() | ||
ls_helpers.session_setup_luasnip({ no_snip_globals = true }) | ||
ls_helpers.loaders["vscode(rtp)"]() | ||
|
||
feed("iall1") | ||
exec_lua("ls.expand()") | ||
screen:expect{grid=[[ | ||
expands? jumps? ^ ! | | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{2:-- INSERT --} |]]} | ||
feed("<esc>") | ||
exec_lua([[require("luasnip.extras.snip_location").jump_to_active_snippet()]]) | ||
screen:expect{grid=[[ | ||
expands? jumps?^ ! | | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
Snippet does not have a source. |]]} | ||
end) | ||
|
||
it("vscode: error-message when parser not installed.", function() | ||
ls_helpers.session_setup_luasnip({ no_snip_globals = true, setup_extend = {loaders_store_source = true} }) | ||
ls_helpers.loaders["vscode(rtp)"]() | ||
|
||
feed("iall1") | ||
exec_lua("ls.expand()") | ||
screen:expect{grid=[[ | ||
expands? jumps? ^ ! | | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{2:-- INSERT --} |]]} | ||
feed("<esc>") | ||
exec_lua([[require("luasnip.extras.snip_location").jump_to_active_snippet()]]) | ||
screen:expect{grid=[[ | ||
^{ | | ||
"snip1": { | | ||
"prefix": "all1", | | ||
"body": [ | | ||
"expands? jumps? $1 $2 !" | | ||
] | | ||
}, | | ||
Could not determine ran...r jsonc) not installed. |]]} | ||
end) | ||
|
||
it("lua: error-message when lua-parser not installed.", function() | ||
ls_helpers.session_setup_luasnip({ no_snip_globals = true, setup_extend = {loaders_store_source = true} }) | ||
ls_helpers.loaders["lua(rtp)"]() | ||
|
||
feed("iall1") | ||
exec_lua("ls.expand()") | ||
screen:expect{grid=[[ | ||
expands? jumps? ^ ! | | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{2:-- INSERT --} |]]} | ||
feed("<esc>") | ||
exec_lua([[require("luasnip.extras.snip_location").jump_to_active_snippet()]]) | ||
screen:expect{grid=[[ | ||
return { | | ||
^ s("all1", fmt("expands? jumps? {} {} !", {| | ||
i(1), i(2) })), | | ||
}, { | | ||
parse("auto???", "autotriggered????????"),| | ||
} | | ||
{0:~ }| | ||
Could not determine ran... for lua not installed. |]]} | ||
end) | ||
|
||
it("snipmate: highlights snippet-definition.", function() | ||
ls_helpers.session_setup_luasnip({ no_snip_globals = true, setup_extend = {loaders_store_source = true} }) | ||
ls_helpers.loaders["snipmate(rtp)"]() | ||
|
||
feed("iall1") | ||
exec_lua("ls.expand()") | ||
screen:expect{grid=[[ | ||
expands? jumps? ^ ! | | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{0:~ }| | ||
{2:-- INSERT --} |]]} | ||
feed("<esc>") | ||
exec_lua([[require("luasnip.extras.snip_location").jump_to_active_snippet()]]) | ||
screen:expect{grid=[[ | ||
# A comment | | ||
{3:^snippet all1 A test snippet} | | ||
{3: expands? jumps? $1 $2 !} | | ||
snippet all2 Another snippet | | ||
multi$1 | | ||
# not removed?? | | ||
line$2 | | ||
|]]} | ||
end) | ||
end) |