mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
fix(lsp): handle template literal as first arg in test function (#17076)
This commit is contained in:
parent
9e977cd6aa
commit
d7f4298015
1 changed files with 87 additions and 26 deletions
|
@ -153,9 +153,7 @@ fn check_call_expr(
|
|||
// (e.g. `test name`)
|
||||
ast::Expr::Tpl(tpl) => {
|
||||
if tpl.quasis.len() == 1 {
|
||||
if let Some(tpl_element) = tpl.quasis.get(0) {
|
||||
maybe_name = Some(tpl_element.raw.to_string());
|
||||
}
|
||||
maybe_name = Some(tpl.quasis[0].raw.to_string());
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
|
@ -205,6 +203,24 @@ fn check_call_expr(
|
|||
}
|
||||
Some((name, steps))
|
||||
}
|
||||
ast::Expr::Tpl(tpl) => {
|
||||
if tpl.quasis.len() == 1 {
|
||||
let mut steps = vec![];
|
||||
match node.args.get(1).map(|es| es.expr.as_ref()) {
|
||||
Some(ast::Expr::Fn(fn_expr)) => {
|
||||
steps = fn_to_steps(parent, level, &fn_expr.function);
|
||||
}
|
||||
Some(ast::Expr::Arrow(arrow_expr)) => {
|
||||
steps = arrow_to_steps(parent, level, arrow_expr);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
Some((tpl.quasis[0].raw.to_string(), steps))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
|
@ -511,17 +527,31 @@ pub mod tests {
|
|||
}
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: `test b`,
|
||||
async fn(t) {
|
||||
await t.step(`b step`, ({ step }) => {
|
||||
await step({
|
||||
name: `sub step`,
|
||||
fn() {}
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test(async function useFnName({ step: s }) {
|
||||
await s("step c", () => {});
|
||||
});
|
||||
|
||||
Deno.test("test b", () => {});
|
||||
Deno.test("test c", () => {});
|
||||
|
||||
Deno.test(`test d`, () => {});
|
||||
|
||||
const { test } = Deno;
|
||||
test("test c", () => {});
|
||||
test("test e", () => {});
|
||||
|
||||
const t = Deno.test;
|
||||
t("test d", () => {});
|
||||
t("test f", () => {});
|
||||
"#;
|
||||
|
||||
let parsed_module = deno_ast::parse_module(deno_ast::ParseParams {
|
||||
|
@ -561,42 +591,73 @@ pub mod tests {
|
|||
}
|
||||
],
|
||||
},
|
||||
TestDefinition {
|
||||
id: "86b4c821900e38fc89f24bceb0e45193608ab3f9d2a6019c7b6a5aceff5d7df2".to_string(),
|
||||
level: 0,
|
||||
name: "useFnName".to_string(),
|
||||
range: new_range(254, 258),
|
||||
steps: vec![
|
||||
TestDefinition {
|
||||
id: "67a390d0084ae5fb88f3510c470a72a553581f1d0d5ba5fa89aee7a754f3953a".to_string(),
|
||||
level: 1,
|
||||
name: "step c".to_string(),
|
||||
range: new_range(313, 314),
|
||||
steps: vec![],
|
||||
}
|
||||
]
|
||||
},
|
||||
TestDefinition {
|
||||
id: "580eda89d7f5e619774c20e13b7d07a8e77c39cba101d60565144d48faa837cb".to_string(),
|
||||
level: 0,
|
||||
name: "test b".to_string(),
|
||||
range: new_range(358, 362),
|
||||
steps: vec![],
|
||||
range: new_range(254, 258),
|
||||
steps: vec![
|
||||
TestDefinition {
|
||||
id: "888e28419fc6c00cadfaad26e1e3e16e09e4322b3579fdfa9cc3fdb75976704a".to_string(),
|
||||
level: 1,
|
||||
name: "b step".to_string(),
|
||||
range: new_range(325, 329),
|
||||
steps: vec![
|
||||
TestDefinition {
|
||||
id: "abf356f59139b77574089615f896a6f501c010985d95b8a93abeb0069ccb2201".to_string(),
|
||||
level: 2,
|
||||
name: "sub step".to_string(),
|
||||
range: new_range(374, 378),
|
||||
steps: vec![],
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
TestDefinition {
|
||||
id: "86b4c821900e38fc89f24bceb0e45193608ab3f9d2a6019c7b6a5aceff5d7df2".to_string(),
|
||||
level: 0,
|
||||
name: "useFnName".to_string(),
|
||||
range: new_range(496, 500),
|
||||
steps: vec![
|
||||
TestDefinition {
|
||||
id:
|
||||
"67a390d0084ae5fb88f3510c470a72a553581f1d0d5ba5fa89aee7a754f3953a".to_string(),
|
||||
level: 1,
|
||||
name: "step c".to_string(),
|
||||
range: new_range(555, 556),
|
||||
steps: vec![],
|
||||
}
|
||||
],
|
||||
},
|
||||
TestDefinition {
|
||||
id: "0b7c6bf3cd617018d33a1bf982a08fe088c5bb54fcd5eb9e802e7c137ec1af94".to_string(),
|
||||
level: 0,
|
||||
name: "test c".to_string(),
|
||||
range: new_range(420, 424),
|
||||
range: new_range(600, 604),
|
||||
steps: vec![],
|
||||
},
|
||||
TestDefinition {
|
||||
id: "69d9fe87f64f5b66cb8b631d4fd2064e8224b8715a049be54276c42189ff8f9f".to_string(),
|
||||
level: 0,
|
||||
name: "test d".to_string(),
|
||||
range: new_range(480, 481),
|
||||
range: new_range(638, 642),
|
||||
steps: vec![],
|
||||
}
|
||||
},
|
||||
TestDefinition {
|
||||
id: "b2fd155c2a5e468eddf77a5eb13f97ddeeeafab322f0fc223ec0810ab2a29d42".to_string(),
|
||||
level: 0,
|
||||
name: "test e".to_string(),
|
||||
range: new_range(700, 704),
|
||||
steps: vec![],
|
||||
},
|
||||
TestDefinition {
|
||||
id: "6387faad3a1f27fb3078a7d350040f4e6b516994076c855a0446943927461f58".to_string(),
|
||||
level: 0,
|
||||
name: "test f".to_string(),
|
||||
range: new_range(760, 761),
|
||||
steps: vec![],
|
||||
},
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue