summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-02-06 15:57:10 -0500
committerGitHub <noreply@github.com>2024-02-06 15:57:10 -0500
commitc6def993e052626be3933de4299bf4b2eb76e48a (patch)
treed377208be4e20bbefb51adb85e546a6f0e65c43b /cli/tests
parenta6b2a4474e50952f28cb933ada0d698fc1055578 (diff)
fix(publish): lazily parse sources (#22301)
Closes #22290
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/publish_tests.rs31
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/add/1.0.0/mod.ts3
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/add/1.0.0_meta.json8
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/add/meta.json5
4 files changed, 47 insertions, 0 deletions
diff --git a/cli/tests/integration/publish_tests.rs b/cli/tests/integration/publish_tests.rs
index dbbbe1912..b15ca5f89 100644
--- a/cli/tests/integration/publish_tests.rs
+++ b/cli/tests/integration/publish_tests.rs
@@ -66,6 +66,37 @@ itest!(invalid_import {
http_server: true,
});
+#[test]
+fn publish_non_exported_files_using_import_map() {
+ let context = publish_context_builder().build();
+ let temp_dir = context.temp_dir().path();
+ temp_dir.join("deno.json").write_json(&json!({
+ "name": "@foo/bar",
+ "version": "1.0.0",
+ "exports": "./mod.ts",
+ "imports": {
+ "@denotest/add": "jsr:@denotest/add@1"
+ }
+ }));
+ // file not in the graph
+ let other_ts = temp_dir.join("_other.ts");
+ other_ts
+ .write("import { add } from '@denotest/add'; console.log(add(1, 3));");
+ let mod_ts = temp_dir.join("mod.ts");
+ mod_ts.write("import { add } from '@denotest/add'; console.log(add(1, 2));");
+ let output = context
+ .new_command()
+ .args("publish --log-level=debug --token 'sadfasdf'")
+ .run();
+ let lines = output.combined_output().split('\n').collect::<Vec<_>>();
+ assert!(lines
+ .iter()
+ .any(|l| l.contains("Unfurling") && l.ends_with("mod.ts")));
+ assert!(lines
+ .iter()
+ .any(|l| l.contains("Unfurling") && l.ends_with("other.ts")));
+}
+
itest!(javascript_missing_decl_file {
args: "publish --token 'sadfasdf'",
output: "publish/javascript_missing_decl_file.out",
diff --git a/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0/mod.ts b/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0/mod.ts
new file mode 100644
index 000000000..8d9b8a22a
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0/mod.ts
@@ -0,0 +1,3 @@
+export function add(a: number, b: number): number {
+ return a + b;
+}
diff --git a/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0_meta.json
new file mode 100644
index 000000000..6eebe2198
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/add/1.0.0_meta.json
@@ -0,0 +1,8 @@
+{
+ "exports": {
+ ".": "./mod.ts"
+ },
+ "moduleGraph1": {
+ "/mod.ts": {}
+ }
+}
diff --git a/cli/tests/testdata/jsr/registry/@denotest/add/meta.json b/cli/tests/testdata/jsr/registry/@denotest/add/meta.json
new file mode 100644
index 000000000..02601e4d0
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/add/meta.json
@@ -0,0 +1,5 @@
+{
+ "versions": {
+ "1.0.0": {}
+ }
+}