Skip to content

Commit

Permalink
test(lsp): format markdown files
Browse files Browse the repository at this point in the history
  • Loading branch information
satyarohith committed Apr 22, 2021
1 parent 620ac16 commit 59b41bd
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cli/lsp/language_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3212,6 +3212,55 @@ mod tests {
harness.run().await;
}

#[tokio::test]
async fn test_format_markdown() {
let mut harness = LspTestHarness::new(vec![
(
LspFixture::Path("initialize_request.json"),
LspResponse::RequestAny,
),
(
LspFixture::Path("initialized_notification.json"),
LspResponse::None,
),
(
LspFixture::Path("did_open_markdown.json"),
LspResponse::None,
),
(
LspFixture::Path("formatting_request_markdown.json"),
LspResponse::Request(
2,
json!([
{
"range": {
"start": { "line": 0, "character": 1 },
"end": { "line": 0, "character": 3 }
},
"newText": ""
},
{
"range": {
"start": { "line": 0, "character": 15 },
"end": { "line": 0, "character": 15 }
},
"newText": "\n"
}
]),
),
),
(
LspFixture::Path("shutdown_request.json"),
LspResponse::Request(3, json!(null)),
),
(
LspFixture::Path("exit_notification.json"),
LspResponse::None,
),
]);
harness.run().await;
}

#[tokio::test]
async fn test_call_hierarchy() {
let mut harness = LspTestHarness::new(vec![
Expand Down
12 changes: 12 additions & 0 deletions cli/tests/lsp/did_open_markdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///a/file.md",
"languageId": "markdown",
"version": 1,
"text": "# Hello World"
}
}
}
14 changes: 14 additions & 0 deletions cli/tests/lsp/formatting_request_markdown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"jsonrpc": "2.0",
"id": 2,
"method": "textDocument/formatting",
"params": {
"textDocument": {
"uri": "file:///a/file.md"
},
"options": {
"tabSize": 2,
"insertSpaces": true
}
}
}

0 comments on commit 59b41bd

Please sign in to comment.