Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: yew-fmt #365

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/formatters/yew_fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,29 @@ pub fn run(snippet_path: &std::path::Path) -> Result<(bool, Option<String>), Mds

execute_command(cmd, snippet_path)
}

#[cfg(test)]
mod test_yew_fmt {
use crate::{formatters::setup_snippet, generated::language_to_ext};

#[test_with::executable(yew-fmt)]
fn it_should_format_rust() {
let input = "pub
async
fn add( a: i32,
b:i32 )-> i32 {a+b}
";

let expected_output = "pub async fn add(a: i32, b: i32) -> i32 {\n a + b\n}\n";

let snippet =
setup_snippet(input, language_to_ext("rust")).expect("it to create a snippet file");

let output = super::run(snippet.path())
.expect("it to be successful")
.1
.expect("it to be some");

assert_eq!(expected_output, output);
}
}
Loading