fix(adapter): format test item name

This commit is contained in:
kbwo 2024-08-04 22:21:16 +09:00
parent 7c5e365167
commit 0f73fa2abd
4 changed files with 16 additions and 12 deletions

View file

@ -253,7 +253,7 @@ mod tests {
test_items,
vec![
TestItem {
id: String::from(":addTest"),
id: String::from("addTest"),
name: String::from("addTest"),
start_position: Range {
start: Position {
@ -277,7 +277,7 @@ mod tests {
}
},
TestItem {
id: String::from(":fail1"),
id: String::from("fail1"),
name: String::from("fail1"),
start_position: Range {
start: Position {
@ -301,7 +301,7 @@ mod tests {
}
},
TestItem {
id: String::from(":fail1"),
id: String::from("fail1"),
name: String::from("fail1"),
start_position: Range {
start: Position {

View file

@ -255,8 +255,8 @@ mod tests {
assert_eq!(
test_items,
vec![TestItem {
id: String::from(":fail"),
name: String::from("fail"),
id: String::from("index:fail"),
name: String::from("index:fail"),
start_position: Range {
start: Position {
line: 1,

View file

@ -151,7 +151,11 @@ pub fn discover_with_treesitter(
test_end_position = end_position;
}
"test.name" => {
let test_name = [namespace, value].join(":");
let test_name = if namespace.is_empty() {
value.to_string()
} else {
[namespace, value].join(":")
};
let test_item = TestItem {
id: test_name.clone(),
name: test_name,

View file

@ -213,8 +213,8 @@ mod tests {
test_items,
vec![
TestItem {
id: String::from(":pass"),
name: String::from("pass"),
id: "describe text:pass".to_string(),
name: "describe text:pass".to_string(),
start_position: Range {
start: Position {
line: 4,
@ -222,7 +222,7 @@ mod tests {
},
end: Position {
line: 4,
character: MAX_CHAR_LENGTH
character: 10000
}
},
end_position: Range {
@ -237,8 +237,8 @@ mod tests {
}
},
TestItem {
id: String::from(":fail"),
name: String::from("fail"),
id: "describe text:fail".to_string(),
name: "describe text:fail".to_string(),
start_position: Range {
start: Position {
line: 8,
@ -246,7 +246,7 @@ mod tests {
},
end: Position {
line: 8,
character: MAX_CHAR_LENGTH
character: 10000
}
},
end_position: Range {