diff options
-rw-r--r-- | cli/lsp/code_lens.rs | 69 |
1 files changed, 64 insertions, 5 deletions
diff --git a/cli/lsp/code_lens.rs b/cli/lsp/code_lens.rs index 3625c10a1..707ff0946 100644 --- a/cli/lsp/code_lens.rs +++ b/cli/lsp/code_lens.rs @@ -108,11 +108,16 @@ impl DenoTestCollector { &key_value_prop.key { if sym == "name" { - if let ast::Expr::Lit(ast::Lit::Str(lit_str)) = - key_value_prop.value.as_ref() - { - let name = lit_str.value.to_string(); - self.add_code_lenses(name, range); + match key_value_prop.value.as_ref() { + ast::Expr::Lit(ast::Lit::Str(lit_str)) => { + let name = lit_str.value.to_string(); + self.add_code_lenses(name, range); + } + ast::Expr::Tpl(tpl) if tpl.quasis.len() == 1 => { + let name = tpl.quasis.first().unwrap().raw.to_string(); + self.add_code_lenses(name, range); + } + _ => {} } } } @@ -130,6 +135,10 @@ impl DenoTestCollector { let name = lit_str.value.to_string(); self.add_code_lenses(name, range); } + ast::Expr::Tpl(tpl) if tpl.quasis.len() == 1 => { + let name = tpl.quasis.first().unwrap().raw.to_string(); + self.add_code_lenses(name, range); + } _ => (), } } @@ -547,6 +556,8 @@ mod tests { Deno.test.ignore("test ignore", () => {}); Deno.test.only("test only", () => {}); + + Deno.test(`test template literal name`, () => {}); "#; let parsed_module = deno_ast::parse_module(deno_ast::ParseParams { specifier: specifier.to_string(), @@ -803,6 +814,54 @@ mod tests { }), data: None, }, + lsp::CodeLens { + range: lsp::Range { + start: lsp::Position { + line: 14, + character: 11, + }, + end: lsp::Position { + line: 14, + character: 15, + }, + }, + command: Some(lsp::Command { + title: "▶\u{fe0e} Run Test".to_string(), + command: "deno.test".to_string(), + arguments: Some(vec![ + json!("https://deno.land/x/mod.ts"), + json!("test template literal name"), + json!({ + "inspect": false, + }), + ]), + }), + data: None, + }, + lsp::CodeLens { + range: lsp::Range { + start: lsp::Position { + line: 14, + character: 11, + }, + end: lsp::Position { + line: 14, + character: 15, + }, + }, + command: Some(lsp::Command { + title: "Debug".to_string(), + command: "deno.test".to_string(), + arguments: Some(vec![ + json!("https://deno.land/x/mod.ts"), + json!("test template literal name"), + json!({ + "inspect": true, + }), + ]), + }), + data: None, + }, ] ); } |