Files
zed/crates/project/tests/integration/lsp_store.rs
T
Piotr OsiewiczandZed Zippy aceff52f8a project: Move tests to integration layer (#47596)
Building project tests takes 6.5s instead of 18s that way.

Release Notes:

- N/A

---------

Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-01-25 21:35:32 +01:00

75 lines
2.2 KiB
Rust

use std::path::Path;
use language::{CodeLabel, HighlightId};
use project::lsp_store::*;
#[test]
fn test_glob_literal_prefix() {
assert_eq!(glob_literal_prefix(Path::new("**/*.js")), Path::new(""));
assert_eq!(
glob_literal_prefix(Path::new("node_modules/**/*.js")),
Path::new("node_modules")
);
assert_eq!(
glob_literal_prefix(Path::new("foo/{bar,baz}.js")),
Path::new("foo")
);
assert_eq!(
glob_literal_prefix(Path::new("foo/bar/baz.js")),
Path::new("foo/bar/baz.js")
);
#[cfg(target_os = "windows")]
{
assert_eq!(glob_literal_prefix(Path::new("**\\*.js")), Path::new(""));
assert_eq!(
glob_literal_prefix(Path::new("node_modules\\**/*.js")),
Path::new("node_modules")
);
assert_eq!(
glob_literal_prefix(Path::new("foo/{bar,baz}.js")),
Path::new("foo")
);
assert_eq!(
glob_literal_prefix(Path::new("foo\\bar\\baz.js")),
Path::new("foo/bar/baz.js")
);
}
}
#[test]
fn test_multi_len_chars_normalization() {
let mut label = CodeLabel::new(
"myElˇ (parameter) myElˇ: {\n foo: string;\n}".to_string(),
0..6,
vec![(0..6, HighlightId(1))],
);
ensure_uniform_list_compatible_label(&mut label);
assert_eq!(
label,
CodeLabel::new(
"myElˇ (parameter) myElˇ: { foo: string; }".to_string(),
0..6,
vec![(0..6, HighlightId(1))],
)
);
}
#[test]
fn test_trailing_newline_in_completion_documentation() {
let doc =
lsp::Documentation::String("Inappropriate argument value (of correct type).\n".to_string());
let completion_doc: CompletionDocumentation = doc.into();
assert!(
matches!(completion_doc, CompletionDocumentation::SingleLine(s) if s == "Inappropriate argument value (of correct type).")
);
let doc = lsp::Documentation::String(" some value \n".to_string());
let completion_doc: CompletionDocumentation = doc.into();
assert!(matches!(
completion_doc,
CompletionDocumentation::SingleLine(s) if s == "some value"
));
}