Skip to content

Commit

Permalink
fix(test lenses): No longer expect "do" on test declaration line (#493)
Browse files Browse the repository at this point in the history
* fix: No longer expect "do" on test declaration line

* test: Fix failing test and remove unused function clause
  • Loading branch information
Étienne Lévesque authored Feb 25, 2021
1 parent 7928174 commit d87c5e5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
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
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

0 comments on commit d87c5e5

Please sign in to comment.