summaryrefslogtreecommitdiff
path: root/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-04-30 20:12:35 +0200
committerGitHub <noreply@github.com>2024-04-30 18:12:35 +0000
commit6cdf81db7c4a41d036eefc17e41ffb8db0cf54a1 (patch)
tree6e21e240c12d8fc9856fbc342aab3d986e338e70 /tests/integration/lsp_tests.rs
parent8c3f8ba13605d1c69eba4272179bce5ca0d10fe3 (diff)
feat(cli): add support for jsxImportSourceTypes (#23419)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r--tests/integration/lsp_tests.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index 2e4b6da30..d000973c0 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -10525,6 +10525,10 @@ export function B() {
}
})
);
+
+ let diagnostics = client.read_diagnostics();
+ println!("{:?}", diagnostics);
+
client.shutdown();
}
@@ -10584,6 +10588,74 @@ fn lsp_jsx_import_source_config_file_automatic_cache() {
client.shutdown();
}
+#[test]
+fn lsp_jsx_import_source_types_pragma() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .build();
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ client.did_open(json!({
+ "textDocument": {
+ "uri": "file:///a/file.tsx",
+ "languageId": "typescriptreact",
+ "version": 1,
+ "text":
+"/** @jsxImportSource http://localhost:4545/jsx */
+/** @jsxImportSourceTypes http://localhost:4545/jsx-types */
+/** @jsxRuntime automatic */
+
+function A() {
+ return <a>Hello</a>;
+}
+
+export function B() {
+ return <A></A>;
+}
+",
+ }
+ }));
+ client.write_request(
+ "workspace/executeCommand",
+ json!({
+ "command": "deno.cache",
+ "arguments": [
+ [],
+ "file:///a/file.tsx",
+ ],
+ }),
+ );
+
+ let diagnostics = client.read_diagnostics();
+ assert_eq!(diagnostics.all().len(), 0);
+
+ let res = client.write_request(
+ "textDocument/hover",
+ json!({
+ "textDocument": {
+ "uri": "file:///a/file.tsx"
+ },
+ "position": { "line": 0, "character": 25 }
+ }),
+ );
+ assert_eq!(
+ res,
+ json!({
+ "contents": {
+ "kind": "markdown",
+ "value": "**Resolved Dependency**\n\n**Code**: http&#8203;://localhost:4545/jsx/jsx-runtime\n\n**Types**: http&#8203;://localhost:4545/jsx-types/jsx-runtime\n",
+ },
+ "range": {
+ "start": { "line": 0, "character": 21 },
+ "end": { "line": 0, "character": 46 }
+ }
+ })
+ );
+
+ client.shutdown();
+}
+
#[derive(Debug, Clone, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
struct TestData {