summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/lsp_tests.rs97
-rw-r--r--cli/tests/testdata/lsp/deno.fmt.exclude.jsonc16
-rw-r--r--cli/tests/testdata/lsp/deno.lint.exclude.jsonc18
3 files changed, 131 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 3d55ac28c..796130083 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+use deno_ast::ModuleSpecifier;
use deno_core::serde::Deserialize;
use deno_core::serde::Serialize;
use deno_core::serde_json;
@@ -1421,6 +1422,61 @@ fn lsp_format_mbc() {
}
#[test]
+fn lsp_format_exclude_with_config() {
+ let temp_dir = TempDir::new().unwrap();
+ let mut params: lsp::InitializeParams =
+ serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
+ let deno_fmt_jsonc =
+ serde_json::to_vec_pretty(&load_fixture("deno.fmt.exclude.jsonc")).unwrap();
+ fs::write(temp_dir.path().join("deno.fmt.jsonc"), deno_fmt_jsonc).unwrap();
+
+ params.root_uri = Some(Url::from_file_path(temp_dir.path()).unwrap());
+ if let Some(Value::Object(mut map)) = params.initialization_options {
+ map.insert("config".to_string(), json!("./deno.fmt.jsonc"));
+ params.initialization_options = Some(Value::Object(map));
+ }
+
+ let deno_exe = deno_exe_path();
+ let mut client = LspClient::new(&deno_exe).unwrap();
+ client
+ .write_request::<_, _, Value>("initialize", params)
+ .unwrap();
+
+ let file_uri =
+ ModuleSpecifier::from_file_path(temp_dir.path().join("ignored.ts"))
+ .unwrap()
+ .to_string();
+ did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": file_uri,
+ "languageId": "typescript",
+ "version": 1,
+ "text": "function myFunc(){}"
+ }
+ }),
+ );
+ let (maybe_res, maybe_err) = client
+ .write_request(
+ "textDocument/formatting",
+ json!({
+ "textDocument": {
+ "uri": file_uri
+ },
+ "options": {
+ "tabSize": 2,
+ "insertSpaces": true
+ }
+ }),
+ )
+ .unwrap();
+ assert!(maybe_err.is_none());
+ assert_eq!(maybe_res, Some(json!(null)));
+ shutdown(&mut client);
+}
+
+#[test]
fn lsp_large_doc_changes() {
let mut client = init("initialize_params.json");
did_open(&mut client, load_fixture("did_open_params_large.json"));
@@ -4048,6 +4104,47 @@ fn lsp_lint_with_config() {
}
#[test]
+fn lsp_lint_exclude_with_config() {
+ let temp_dir = TempDir::new().unwrap();
+ let mut params: lsp::InitializeParams =
+ serde_json::from_value(load_fixture("initialize_params.json")).unwrap();
+ let deno_lint_jsonc =
+ serde_json::to_vec_pretty(&load_fixture("deno.lint.exclude.jsonc"))
+ .unwrap();
+ fs::write(temp_dir.path().join("deno.lint.jsonc"), deno_lint_jsonc).unwrap();
+
+ params.root_uri = Some(Url::from_file_path(temp_dir.path()).unwrap());
+ if let Some(Value::Object(mut map)) = params.initialization_options {
+ map.insert("config".to_string(), json!("./deno.lint.jsonc"));
+ params.initialization_options = Some(Value::Object(map));
+ }
+
+ let deno_exe = deno_exe_path();
+ let mut client = LspClient::new(&deno_exe).unwrap();
+ client
+ .write_request::<_, _, Value>("initialize", params)
+ .unwrap();
+
+ let diagnostics = did_open(
+ &mut client,
+ json!({
+ "textDocument": {
+ "uri": ModuleSpecifier::from_file_path(temp_dir.path().join("ignored.ts")).unwrap().to_string(),
+ "languageId": "typescript",
+ "version": 1,
+ "text": "// TODO: fixme\nexport async function non_camel_case() {\nconsole.log(\"finished!\")\n}"
+ }
+ }),
+ );
+ let diagnostics = diagnostics
+ .into_iter()
+ .flat_map(|x| x.diagnostics)
+ .collect::<Vec<_>>();
+ assert_eq!(diagnostics, Vec::new());
+ shutdown(&mut client);
+}
+
+#[test]
fn lsp_jsx_import_source_pragma() {
let _g = http_server();
let mut client = init("initialize_params.json");
diff --git a/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc b/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc
new file mode 100644
index 000000000..246a40316
--- /dev/null
+++ b/cli/tests/testdata/lsp/deno.fmt.exclude.jsonc
@@ -0,0 +1,16 @@
+{
+ "fmt": {
+ "files": {
+ "exclude": [
+ "ignored.ts"
+ ]
+ },
+ "options": {
+ "useTabs": true,
+ "lineWidth": 40,
+ "indentWidth": 8,
+ "singleQuote": true,
+ "proseWrap": "always"
+ }
+ }
+}
diff --git a/cli/tests/testdata/lsp/deno.lint.exclude.jsonc b/cli/tests/testdata/lsp/deno.lint.exclude.jsonc
new file mode 100644
index 000000000..89f6108ec
--- /dev/null
+++ b/cli/tests/testdata/lsp/deno.lint.exclude.jsonc
@@ -0,0 +1,18 @@
+{
+ "lint": {
+ "files": {
+ "exclude": [
+ "ignored.ts"
+ ]
+ },
+ "rules": {
+ "exclude": [
+ "camelcase"
+ ],
+ "include": [
+ "ban-untagged-todo"
+ ],
+ "tags": []
+ }
+ }
+}