use crate::runners::CommandType;
#[inline]
pub fn set_args(
mut cmd: std::process::Command,
file_path: &std::path::Path,
) -> std::process::Command {
cmd.arg("fmt");
cmd.arg("--quiet");
cmd.arg(file_path);
cmd
}
pub const COMMANDS: [CommandType; 1] = [CommandType::Direct("deno")];
#[cfg(test)]
mod test_deno_fmt {
#[test_with::executable(deno)]
fn test_deno_fmt_javascript_d7445fa122fcd5cc() {
let input = r#"
async function asyncAddition(a,b){
return a+b
}
"#;
let output = r#"async function asyncAddition(a, b) {
return a + b;
}
"#;
let file_ext = crate::fttype::get_file_extension("javascript");
let snippet =
crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
let result =
crate::execution::run_tools(&super::COMMANDS, snippet.path(), super::set_args, 0)
.expect("it to be successful")
.1
.expect("it to be some");
assert_eq!(result, output);
}
#[test_with::executable(deno)]
fn test_deno_fmt_typescript_857476c85438ce71() {
let input = r#"
async function asyncAddition( a: number,b:number ) :Promise< number>
{
return a+b
}
"#;
let output = r#"async function asyncAddition(a: number, b: number): Promise<number> {
return a + b;
}
"#;
let file_ext = crate::fttype::get_file_extension("typescript");
let snippet =
crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
let result =
crate::execution::run_tools(&super::COMMANDS, snippet.path(), super::set_args, 0)
.expect("it to be successful")
.1
.expect("it to be some");
assert_eq!(result, output);
}
#[test_with::executable(deno)]
fn test_deno_fmt_json_d426a9ade74002d2() {
let input = r#"
{
"key": "value",
"key2": [
"value2",
"value3",
1
, null]
}
"#;
let output = r#"{
"key": "value",
"key2": [
"value2",
"value3",
1,
null
]
}
"#;
let file_ext = crate::fttype::get_file_extension("json");
let snippet =
crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
let result =
crate::execution::run_tools(&super::COMMANDS, snippet.path(), super::set_args, 0)
.expect("it to be successful")
.1
.expect("it to be some");
assert_eq!(result, output);
}
}