test: update package hover tests

This commit is contained in:
QuadnucYard 2025-12-10 11:02:12 +08:00
parent e3ac855681
commit 9877331638
8 changed files with 23 additions and 8 deletions

View file

@ -4,4 +4,4 @@ pub mod pack;
pub use pack::*;
pub mod registry;
pub use registry::{PackageError, PackageRegistry, PackageSpec};
pub use registry::{PackageError, PackageRegistry, PackageSpec, PackageSpecExt};

View file

@ -0,0 +1 @@
#import /* position after */ "@local/local-example:0.0.1"

View file

@ -0,0 +1,16 @@
---
source: crates/tinymist-query/src/hover.rs
expression: content
input_file: crates/tinymist-query/src/fixtures/hover/package_import_local.typ
---
Range: 0:29:0:57
This is a local package
**Package:** `@local/local-example:0.0.1`
✅ **Up to date** (latest version)
**Description:** example package (mock).
**Available Versions** (click to replace):
- **0.0.1** /

View file

@ -1,7 +1,7 @@
---
source: crates/tinymist-query/src/hover.rs
expression: content
input_file: crates/tinymist-query/src/fixtures/hover/package_import.typ
input_file: crates/tinymist-query/src/fixtures/hover/package_import_not_found.typ
---
Range: 0:29:0:52

View file

@ -8,7 +8,7 @@ Range: 0:29:0:53
🌌 [Universe](https://typst.app/universe/package/example)
**Package:** `@preview/example:0.1.0`
⚠️ **Newer version available:** 0.1.1
⚠️ **Newer version available: 0.1.1**
**Description:** example package (mock).

View file

@ -3,7 +3,7 @@ use std::cmp::Reverse;
use std::str::FromStr;
use tinymist_std::typst::TypstDocument;
use tinymist_world::package::PackageSpec;
use tinymist_world::package::{PackageSpec, PackageSpecExt};
use typst::foundations::repr::separated_list;
use typst_shim::syntax::LinkedNodeExt;
@ -247,9 +247,6 @@ impl HoverWorker<'_> {
package_spec: &PackageSpec,
import_str_node: &LinkedNode,
) -> String {
#[cfg(feature = "local-registry")]
use tinymist_world::package::registry::PackageSpecExt;
let versionless_spec = package_spec.versionless();
// Get all matching packages
@ -310,7 +307,7 @@ impl HoverWorker<'_> {
}
// Package header
if package_spec.namespace == "local" {
if !package_spec.is_preview() {
info.push_str(" This is a local package\n\n");
}

View file

@ -105,6 +105,7 @@ pub fn run_with_ctx_<T>(
vec![
dummy_package_from_spec(&PackageSpec::from_str("@preview/example:0.1.0").unwrap()),
dummy_package_from_spec(&PackageSpec::from_str("@preview/example:0.1.1").unwrap()),
dummy_package_from_spec(&PackageSpec::from_str("@local/local-example:0.0.1").unwrap()),
]
});
ctx.test_completion_files(|| paths.clone());