Skip to content

chore: fix formatting in test file #23

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

Merged
merged 1 commit into from
Jun 23, 2023
Merged
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
144 changes: 59 additions & 85 deletions test/next_ls_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ defmodule NextLSTest do
params: %{}
})

assert_notification "window/logMessage",
%{"message" => "[NextLS] Runtime ready..."}
assert_notification "window/logMessage", %{"message" => "[NextLS] Runtime ready..."}

assert :ok ==
request(client, %{
Expand All @@ -63,7 +62,7 @@ defmodule NextLSTest do
params: nil
})

assert_result(2, nil)
assert_result 2, nil
end

test "returns method not found for unimplemented requests", %{
Expand All @@ -90,39 +89,30 @@ defmodule NextLSTest do
}
})

assert_notification(
"window/logMessage",
%{
"message" => "[NextLS] Method Not Found: textDocument/documentSymbol",
"type" => 2
}
)
assert_notification "window/logMessage", %{
"message" => "[NextLS] Method Not Found: textDocument/documentSymbol",
"type" => 2
}

assert_error(
^id,
%{
"code" => -32_601,
"message" => "Method Not Found: textDocument/documentSymbol"
}
)
assert_error ^id, %{
"code" => -32_601,
"message" => "Method Not Found: textDocument/documentSymbol"
}
end

test "can initialize the server" do
assert_result(
1,
%{
"capabilities" => %{
"textDocumentSync" => %{
"openClose" => true,
"save" => %{
"includeText" => true
},
"change" => 1
}
},
"serverInfo" => %{"name" => "NextLS"}
}
)
assert_result 1, %{
"capabilities" => %{
"textDocumentSync" => %{
"openClose" => true,
"save" => %{
"includeText" => true
},
"change" => 1
}
},
"serverInfo" => %{"name" => "NextLS"}
}
end

test "publishes diagnostics once the client has initialized", %{client: client, cwd: cwd} do
Expand All @@ -133,37 +123,28 @@ defmodule NextLSTest do
params: %{}
})

assert_notification(
"window/logMessage",
%{
"message" => "[NextLS] LSP Initialized!",
"type" => 4
}
)
assert_notification "window/logMessage", %{
"message" => "[NextLS] LSP Initialized!",
"type" => 4
}

assert_notification("$/progress", %{"value" => %{"kind" => "begin", "title" => "Initializing NextLS runtime..."}})
assert_notification "$/progress", %{"value" => %{"kind" => "begin", "title" => "Initializing NextLS runtime..."}}

assert_notification(
"$/progress",
%{
"value" => %{
"kind" => "end",
"message" => "NextLS runtime has initialized!"
}
assert_notification "$/progress", %{
"value" => %{
"kind" => "end",
"message" => "NextLS runtime has initialized!"
}
)
}

assert_notification("$/progress", %{"value" => %{"kind" => "begin", "title" => "Compiling..."}})
assert_notification "$/progress", %{"value" => %{"kind" => "begin", "title" => "Compiling..."}}

assert_notification(
"$/progress",
%{
"value" => %{
"kind" => "end",
"message" => "Compiled!"
}
assert_notification "$/progress", %{
"value" => %{
"kind" => "end",
"message" => "Compiled!"
}
)
}

for file <- ["bar.ex"] do
uri =
Expand All @@ -173,24 +154,21 @@ defmodule NextLSTest do
path: Path.join([cwd, "lib", file])
})

assert_notification(
"textDocument/publishDiagnostics",
%{
"uri" => ^uri,
"diagnostics" => [
%{
"source" => "Elixir",
"severity" => 2,
"message" =>
"variable \"arg1\" is unused (if the variable is not meant to be used, prefix it with an underscore)",
"range" => %{
"start" => %{"line" => 1, "character" => 0},
"end" => %{"line" => 1, "character" => 999}
}
assert_notification "textDocument/publishDiagnostics", %{
"uri" => ^uri,
"diagnostics" => [
%{
"source" => "Elixir",
"severity" => 2,
"message" =>
"variable \"arg1\" is unused (if the variable is not meant to be used, prefix it with an underscore)",
"range" => %{
"start" => %{"line" => 1, "character" => 0},
"end" => %{"line" => 1, "character" => 999}
}
]
}
)
}
]
}
end
end

Expand Down Expand Up @@ -240,8 +218,7 @@ defmodule NextLSTest do

assert_result 2, nil

assert_notification "window/logMessage",
%{"message" => "[NextLS] Runtime ready..."}
assert_notification "window/logMessage", %{"message" => "[NextLS] Runtime ready..."}

request client, %{
method: "textDocument/formatting",
Expand All @@ -266,14 +243,11 @@ defmodule NextLSTest do
end
"""

assert_result(
3,
[
%{
"newText" => ^new_text,
"range" => %{"start" => %{"character" => 0, "line" => 0}, "end" => %{"character" => 0, "line" => 8}}
}
]
)
assert_result 3, [
%{
"newText" => ^new_text,
"range" => %{"start" => %{"character" => 0, "line" => 0}, "end" => %{"character" => 0, "line" => 8}}
}
]
end
end