Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test lenses): No longer expect "do" on test declaration line #493

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.Test do
end
end

def code_lens(_uri, _text), do: {:ok, []}

defp get_test_lenses(test_blocks, file_path, project_dir) do
args = fn block ->
%{
Expand Down Expand Up @@ -93,7 +91,7 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.Test do
end)

%{"name" => test_name} =
~r/^\s*test "(?<name>.*)"(,.*)? do/
~r/^\s*test "(?<name>.*)"(,.*)?/
|> Regex.named_captures(Enum.at(source_lines, line - 1))

%TestBlock{name: test_name, describe: describe, line: line}
Expand Down
23 changes: 23 additions & 0 deletions apps/language_server/test/providers/code_lens/test_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,29 @@ defmodule ElixirLS.LanguageServer.Providers.CodeLens.TestTest do
end
end

test "returns lenses for tests with multiline context parameters" do
Blond11516 marked this conversation as resolved.
Show resolved Hide resolved
text = """
defmodule MyModule do
use ExUnit.Case

test "test1", %{
} do
end
end
"""

uri = "file:///project/file.ex"

{:ok, lenses} = CodeLens.Test.code_lens(uri, text, @project_dir)

assert Enum.member?(
lenses,
build_code_lens(3, :test, maybe_convert_path_separators("/project/file.ex"), %{
"testName" => "test1"
})
)
end

defp build_code_lens(line, target, file_path, args) do
arguments =
%{
Expand Down