summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/lsp_tests.rs51
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-a.js2
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.d.ts1
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.js3
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/package.json3
5 files changed, 59 insertions, 1 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index d60d14bea..2fc3d29e8 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -6450,6 +6450,7 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() {
"imports": {
"print_hello": "http://localhost:4545/subdir/print_hello.ts",
"chalk": "npm:chalk@~5",
+ "nested/": "npm:/@denotest/types-exports-subpaths@1/nested/",
"types-exports-subpaths/": "npm:/@denotest/types-exports-subpaths@1/"
}
}"#;
@@ -6470,6 +6471,7 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() {
"import _test1 from 'npm:chalk@^5.0';\n",
"import chalk from 'npm:chalk@~5';\n",
"import chalk from 'npm:chalk@~5';\n",
+ "import {entryB} from 'npm:@denotest/types-exports-subpaths@1/nested/entry-b';\n",
"import {printHello} from 'print_hello';\n",
"\n",
),
@@ -6483,6 +6485,7 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() {
"arguments": [
[
"npm:@denotest/types-exports-subpaths@1/client",
+ "npm:@denotest/types-exports-subpaths@1/nested/entry-b",
"npm:chalk@^5.0",
"npm:chalk@~5",
"http://localhost:4545/subdir/print_hello.ts",
@@ -6822,6 +6825,54 @@ fn lsp_completions_auto_import_and_quick_fix_with_import_map() {
}
}])
);
+
+ // try auto-import with npm package with sub-path on value side of import map
+ client.did_open(json!({
+ "textDocument": {
+ "uri": "file:///a/nested_path.ts",
+ "languageId": "typescript",
+ "version": 1,
+ "text": "entry",
+ }
+ }));
+ let list = client.get_completion_list(
+ "file:///a/nested_path.ts",
+ (0, 5),
+ json!({ "triggerKind": 1 }),
+ );
+ assert!(!list.is_incomplete);
+ let item = list
+ .items
+ .iter()
+ .find(|item| item.label == "entryB")
+ .unwrap();
+
+ let res = client.write_request("completionItem/resolve", item);
+ assert_eq!(
+ res,
+ json!({
+ "label": "entryB",
+ "labelDetails": {
+ "description": "nested/entry-b",
+ },
+ "kind": 3,
+ "detail": "function entryB(): \"b\"",
+ "documentation": {
+ "kind": "markdown",
+ "value": ""
+ },
+ "sortText": "￿16_0",
+ "additionalTextEdits": [
+ {
+ "range": {
+ "start": { "line": 0, "character": 0 },
+ "end": { "line": 0, "character": 0 }
+ },
+ "newText": "import { entryB } from \"nested/entry-b\";\n\n"
+ }
+ ]
+ })
+ );
}
#[test]
diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-a.js b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-a.js
index 070b1ccbd..84f1f2c94 100644
--- a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-a.js
+++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-a.js
@@ -1,3 +1,3 @@
-export function entryC() {
+export function entryA() {
return 12;
}
diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.d.ts b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.d.ts
new file mode 100644
index 000000000..382d1995e
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.d.ts
@@ -0,0 +1 @@
+export function entryB(): "b";
diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.js b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.js
new file mode 100644
index 000000000..162d4f190
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/dist/entry-b.js
@@ -0,0 +1,3 @@
+export function entryB() {
+ return "b";
+}
diff --git a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/package.json
index 169017560..cc43cf2ed 100644
--- a/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/package.json
+++ b/cli/tests/testdata/npm/registry/@denotest/types-exports-subpaths/1.0.0/package.json
@@ -18,6 +18,9 @@
},
"./entry-a": {
"import": "./dist/entry-a.js"
+ },
+ "./nested/entry-b": {
+ "import": "./dist/entry-b.js"
}
}
}