fix tests

This commit is contained in:
Smit Barmase
2025-11-25 20:50:18 +05:30
parent 6c54beb173
commit fdff6d2f5c
2 changed files with 18 additions and 24 deletions

View File

@@ -242,6 +242,7 @@ async fn test_fuzzy_over_sort_positions(cx: &mut TestAppContext) {
#[gpui::test]
async fn test_semver_label_sort_by_latest_version(cx: &mut TestAppContext) {
let completions = vec![
CompletionBuilder::new("10.4.112", None, "00000000", None),
CompletionBuilder::new("10.4.22", None, "00000001", None),
CompletionBuilder::new("10.4.2", None, "00000015", None),
CompletionBuilder::new("10.4.20", None, "00000012", None),
@@ -249,38 +250,30 @@ async fn test_semver_label_sort_by_latest_version(cx: &mut TestAppContext) {
CompletionBuilder::new("10.4.12", None, "00000014", None),
// Pre-release versions
CompletionBuilder::new("10.4.22-alpha", None, "00000007", None),
CompletionBuilder::new("10.4.22-alpha.1", None, "00000006", None),
CompletionBuilder::new("10.4.22-alpha.2", None, "00000005", None),
CompletionBuilder::new("10.4.22-beta", None, "00000004", None),
CompletionBuilder::new("10.4.22-beta.1", None, "00000003", None),
CompletionBuilder::new("10.4.22-rc.1", None, "00000002", None),
CompletionBuilder::new("10.4.20-beta.1", None, "00000013", None),
// Build metadata versions
CompletionBuilder::new("10.4.21+build.123", None, "00000009", None),
CompletionBuilder::new("10.4.21+build.456", None, "00000008", None),
CompletionBuilder::new("10.4.20+20210327", None, "00000011", None),
];
let matches = filter_and_sort_matches("2", &completions, SnippetSortOrder::default(), cx).await;
let matches =
filter_and_sort_matches("10.4.2", &completions, SnippetSortOrder::default(), cx).await;
// Exact match comes first
assert_eq!(matches[0].string, "10.4.2");
// Ordered by recency
assert_eq!(matches[1].string, "10.4.112");
assert_eq!(matches[2].string, "10.4.22");
// Within pre-releases: rc.1 > beta.1 > beta > alpha.2 > alpha.1 > alpha
assert_eq!(matches[0].string, "10.4.22");
assert_eq!(matches[1].string, "10.4.22-rc.1");
assert_eq!(matches[2].string, "10.4.22-beta.1");
assert_eq!(matches[3].string, "10.4.22-beta");
assert_eq!(matches[4].string, "10.4.22-alpha.2");
assert_eq!(matches[5].string, "10.4.22-alpha.1");
assert_eq!(matches[6].string, "10.4.22-alpha");
assert_eq!(matches[7].string, "10.4.21+build.456");
assert_eq!(matches[8].string, "10.4.21+build.123");
assert_eq!(matches[9].string, "10.4.21");
assert_eq!(matches[10].string, "10.4.20+20210327");
assert_eq!(matches[11].string, "10.4.20");
assert_eq!(matches[12].string, "10.4.20-beta.1");
// TODO: we still need to figure how to handle case where
// we might want to prefer sort_text over sort_positions and sort_score
assert_eq!(matches[13].string, "10.4.2");
assert_eq!(matches[14].string, "10.4.12");
assert_eq!(matches[3].string, "10.4.22-rc.1");
assert_eq!(matches[4].string, "10.4.22-beta.1");
assert_eq!(matches[8].string, "10.4.22-alpha");
assert_eq!(matches[10].string, "10.4.21+build.123");
assert_eq!(matches[11].string, "10.4.21");
assert_eq!(matches[12].string, "10.4.20+20210327");
assert_eq!(matches[13].string, "10.4.20");
assert_eq!(matches[15].string, "10.4.12");
}
async fn test_for_each_prefix<F>(

View File

@@ -11,5 +11,6 @@ brackets = [
tab_size = 2
prettier_parser_name = "json"
debuggers = ["JavaScript"]
[overrides.string]
completion_query_characters = [":", " "]
completion_query_characters = [":", " ", "."]